Subversion Repositories pspware

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
350 Oobles 1
/*
2
 * PSP Software Development Kit - http://www.pspdev.org
3
 * -----------------------------------------------------------------------
4
 * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
5
 *
6
 * main.c - Kernel mode loadlib PRX.
7
 *
8
 * Copyright (c) 2005 David Ryan <oobles@hotmail.com>
9
 *
10
 * $Id: main.c 1531 2005-12-07 18:27:12Z tyranid $
11
 */
12
#include <stdlib.h>
13
#include <pspkernel.h>
14
#include <stdio.h>
15
#include <string.h>
16
#include <unistd.h>
17
#include <sys/stat.h>
18
#include "luamodule.h"
19
#include "libs.h"
20
 
21
PSP_MODULE_INFO("LOADLIB", 0x1000, 1, 1);
22
PSP_HEAP_SIZE_KB(1);
23
PSP_NO_CREATE_MAIN_THREAD();
24
 
25
static char modulePath[256];
26
 
27
static void setModulePath()
28
{
29
        getcwd( modulePath, 256 );
30
}
31
 
32
void** findFunction( SceUID id, const char *library, const char * name )
33
{
34
        return libsFindExportAddrByName( id, library, name );
35
}
36
 
37
 
38
SceUID psploadlib( char * name, char * init )
39
{
40
        char path[256];
41
        u32 loadResult;
42
        u32 startResult;
43
        int status;
44
 
45
 
46
        if (!name) return -1;
47
 
48
        // check if the module is already loaded.
49
        SceModule *pMod;
50
        pMod = sceKernelFindModuleByName( name );
51
        if (pMod != NULL ) {
52
                loadResult = pMod->modid;
53
                return loadResult;
54
        }
55
 
56
        strcpy( path, modulePath );
57
        strcat( path, "/" );
58
        strcat( path, name );
59
        strcat( path, ".lrx" );
60
 
61
        loadResult = sceKernelLoadModule(path,0, NULL);
62
        if (loadResult & 0x80000000)
63
        {
64
                return loadResult;
65
        }
66
 
67
        startResult = sceKernelStartModule( loadResult, strlen(path)+1,(void*) path, &status, NULL );
68
        if ( loadResult != startResult )
69
        {
70
                return -1;
71
        }
72
 
73
        return loadResult;
74
}
75
 
76
 
77
int main(int argc, char *argv[] )
78
{
79
        setModulePath();
80
        return 0;
81
}
82