/*************************************************************************** modulos.c - description ------------------- begin : Sat Jun 23 2001 copyright : (C) 2001 by Sion Entertainment email : bugs@edivcentral.com ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifdef _WIN32 #include "dll_load.h" #include HINSTANCE hDLL[999]; int dll_n; #else #include #include #include #endif #include #include #include #include "modulos.h" #include "extern.h" int imem_temp; int iloc_temp; TYPEOF_ExportaFuncs *ExportaFuncs[100]; int funciones; void dll_func() // ke original, no? XD { #ifdef WIN32 int buscafich; struct _finddata_t fichero_dll; // busqueda de DLLs #else int i; DIR *directorio; struct dirent *fichero_dll; #endif numdlls=0; #ifdef WIN32 // Inicializa la carga de DLLs CheckWindowsVersion(); InitializeDLLLoad(); #endif #ifdef WIN32 // Busca las DLLs que hay en el directorio buscafich = _findfirst("dll\\*.dll", &fichero_dll); if (buscafich==-1) { printf("No se encuentra ninguna DLL"); exit(1); } printf("DLL encontrada: %s\n",fichero_dll.name); // guarda el nombre de fichero en la tabla de DLLs printf("\nGuardando el nombre de la dll..."); dlls[0].nombre=e_malloc(strlen(fichero_dll.name)+1); strcpy(dlls[0].nombre,fichero_dll.name); printf("\nGuardado el nombre de la dll..."); // importa las funciones de la DLL strcpy(fichdll,"dll\\"); strcat(fichdll,fichero_dll.name); leedll(); numdlls=1; // hace lo mismo con el resto while(1) { if(_findnext(buscafich,&fichero_dll)==0) { printf("DLL encontrada: %s\n",fichero_dll.name); strcpy(fichdll,"dll\\"); strcat(fichdll,fichero_dll.name); // dlls[numdlls].nfuncs=0; if(!leedll()) { dlls[numdlls].nombre=e_malloc(strlen(fichero_dll.name)+1); strcpy(dlls[numdlls].nombre,fichero_dll.name); dlls[numdlls].usado=0; numdlls++; } } else break; } #else // si estamos en Linux directorio=opendir("so"); if(!directorio) { printf("Directorio so/ no encontrado\n"); exit(1); } // Nos saltamos las dos primeras entradas "./" y "../" for(i=0;i<2;i++) { fichero_dll=readdir(directorio); if(fichero_dll==0) { printf("No se encuentra ninguna librería\n"); exit(1); } } // Busca las .so while (1) { fichero_dll=readdir(directorio); if(fichero_dll==0) break; if(fichero_dll->d_type==DT_REG) { printf("Librería encontrada: so/%s\n",fichero_dll->d_name); strcpy(fichdll,"so/"); strcat(fichdll,fichero_dll->d_name); // dlls[numdlls].nfuncs=0; if(!leedll()) { dlls[numdlls].nombre=e_malloc(strlen(fichero_dll->d_name)+1); strcpy(dlls[numdlls].nombre,fichero_dll->d_name); dlls[numdlls].usado=0; numdlls++; } } } if(numdlls==0) { printf("No se encuentra ninguna librería\n"); exit(1); } #endif } void dll_func2() { int i; for(i=0;i