dll exports...

02/04/2009 15:01 Tyrar#1
hi, hab grad ein problem mit den exports...
original:
[Only registered and activated users can see links. Click Here To Register...]
meine:
[Only registered and activated users can see links. Click Here To Register...]

wieso wird meine func iwie umbenannt?
hier ma der code:
Code:
int __declspec(dllexport) __stdcall Py_SetProgramName()
{
    static FARPROC Py_SetProgramNameOrig = 0;
    int result; // Für das Resultat des Aufrufes der Originalfunktion
    if (Py_SetProgramNameOrig == 0) { // Original-Funktion finden
        Py_SetProgramNameOrig = GetProcAddress(lib, "Py_SetProgramName");
    }

    result = Py_SetProgramNameOrig();

    return result;
}
02/04/2009 21:15 Tyrar#2
sry für doppelpost
problem gelöst: lag iwie an meiner ide!

nächstes prob:
ich bekomme ne meldung dass in meiner dll kein einsprungpunkt für die funktion is, aber exports sind drin
02/04/2009 21:33 __wadim#3
hast du eine library datei erstellt mit den zu exportierenden funktionen?
02/04/2009 21:37 Tyrar#4
Quote:
Originally Posted by __wadim View Post
hast du eine library datei erstellt mit den zu exportierenden funktionen?
jo, spiel disassembliert, nötigen funktionen rausgesucht, in meine dll gepackt, exportiert, in den spielordner eingefügt, fehler bekommen.
hab hier ne grobe übersicht:
Code:
int __declspec(dllexport) __stdcall Py_SetProgramName() { return 0; }                                   
int __declspec(dllexport) __stdcall PyImport_AddModule() { return 0; }                                   
int __declspec(dllexport) __stdcall PyModule_GetDict() { return 0; }                                     
int __declspec(dllexport) __stdcall PyImport_ImportModule() { return 0; }                                
int __declspec(dllexport) __stdcall PyDict_SetItemString() { return 0; }                                 
int __declspec(dllexport) __stdcall PyRun_String() { return 0; }                                         
int __declspec(dllexport) __stdcall Py_Initialize() { return 0; }                                        
int __declspec(dllexport) __stdcall PyErr_Fetch() { return 0; }                                          
int __declspec(dllexport) __stdcall PyNumber_Check() { return 0; }                                       
int __declspec(dllexport) __stdcall PyObject_GetAttr() { return 0; }                                     
int __declspec(dllexport) __stdcall PyObject_GetAttrString() { return 0; }                               
int __declspec(dllexport) __stdcall PyErr_Clear() { return 0; }                                          
int __declspec(dllexport) __stdcall PyCallable_Check() { return 0; }                                     
int __declspec(dllexport) __stdcall PyObject_CallObject() { return 0; }                                  
int __declspec(dllexport) __stdcall PyErr_Print() { return 0; }                                          
int __declspec(dllexport) __stdcall PyString_Type() { return 0; }                                        
int __declspec(dllexport) __stdcall PyString_AsString() { return 0; }                                    
int __declspec(dllexport) __stdcall PyFloat_AsDouble() { return 0; }                                     
int __declspec(dllexport) __stdcall _Py_NoneStruct() { return 0; }                                       
int __declspec(dllexport) __stdcall PyErr_BadArgument() { return 0; }                                    
int __declspec(dllexport) __stdcall PyList_New() { return 0; }                                           
int __declspec(dllexport) __stdcall PyString_FromString() { return 0; }                                  
int __declspec(dllexport) __stdcall PyList_Append() { return 0; }                                        
int __declspec(dllexport) __stdcall PyTuple_Type() { return 0; }                                         
int __declspec(dllexport) __stdcall PyInt_AsLong() { return 0; }                                        
int __declspec(dllexport) __stdcall PyString_InternFromString() { return 0; }                            
int __declspec(dllexport) __stdcall Py_Finalize() { return 0; }                                          
int __declspec(dllexport) __stdcall PyExc_RuntimeError() { return 0; }                                   
int __declspec(dllexport) __stdcall PyErr_SetString() { return 0; }                                      
int __declspec(dllexport) __stdcall PyTuple_GetItem() { return 0; }                                      
int __declspec(dllexport) __stdcall PyDict_Type() { return 0; }                                          
int __declspec(dllexport) __stdcall PyType_IsSubtype() { return 0; }                                     
int __declspec(dllexport) __stdcall PyDict_GetItemString() { return 0; }                                 
int __declspec(dllexport) __stdcall PyLong_AsLong() { return 0; }                                        
int __declspec(dllexport) __stdcall PyTuple_Size() { return 0; }                                         
int __declspec(dllexport) __stdcall Py_InitModule4() { return 0; }                                       
int __declspec(dllexport) __stdcall PyModule_AddIntConstant() { return 0; }                              
int __declspec(dllexport) __stdcall Py_BuildValue() { return 0; }
und mein def file sieht so aus:
Code:
LIBRARY"python22"
EXPORTS
Py_SetProgramName @ 1;
PyImport_AddModule @ 2;
PyModule_GetDict @ 3;
PyImport_ImportModule @ 4;
PyDict_SetItemString @ 5;
PyRun_String @ 6;
Py_Initialize @ 7;
PyErr_Fetch @ 8;
PyNumber_Check @ 9;
PyObject_GetAttr @ 10;
PyObject_GetAttrString @ 11;
PyErr_Clear @ 12;
PyCallable_Check @ 13;
PyObject_CallObject @ 14;
PyErr_Print @ 15;
PyString_Type @ 16;
PyString_AsString @ 17;
PyFloat_AsDouble @ 18;
_Py_NoneStruct @ 19;
PyErr_BadArgument @ 20;
PyList_New @ 21;
PyString_FromString @ 22;
PyList_Append @ 23;
PyTuple_Type @ 24;
PyInt_AsLong @ 25;
PyString_InternFromString @ 26;
Py_Finalize @ 27;
PyExc_RuntimeError @ 28;
PyErr_SetString @ 29;
PyTuple_GetItem @ 30;
PyDict_Type @ 31;
PyType_IsSubtype @ 32;
PyDict_GetItemString @ 33;
PyLong_AsLong @ 34;
PyTuple_Size @ 35;
Py_InitModule4 @ 36;
PyModule_AddIntConstant @ 37;
Py_BuildValue @ 38;
beim disassemblieren sind alle funktionen drin!
hier mal die dll: [Only registered and activated users can see links. Click Here To Register...]
02/06/2009 04:49 schlurmann#5
Dein erstes Problem lässt sich mit einer Definition der Funktionen in einem extern "C" Block lösen.

Das zweite Problem klingt, als hättest du keine DllMain definiert.
02/06/2009 11:57 Tyrar#6
Quote:
Originally Posted by schlurmann View Post
Dein erstes Problem lässt sich mit einer Definition der Funktionen in einem extern "C" Block lösen.

Das zweite Problem klingt, als hättest du keine DllMain definiert.
exports.h (wird eingebunden):
Code:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

extern "C"
{
int __declspec(dllexport) __stdcall Py_SetProgramName();                       
int __declspec(dllexport) __stdcall PyImport_AddModule();                       
int __declspec(dllexport) __stdcall PyModule_GetDict();                                
int __declspec(dllexport) __stdcall PyImport_ImportModule();                       
int __declspec(dllexport) __stdcall PyDict_SetItemString();                   
int __declspec(dllexport) __stdcall PyRun_String();                            
int __declspec(dllexport) __stdcall Py_Initialize();                           
int __declspec(dllexport) __stdcall PyErr_Fetch();                              
int __declspec(dllexport) __stdcall PyNumber_Check();                                      
int __declspec(dllexport) __stdcall PyObject_GetAttr();                                  
int __declspec(dllexport) __stdcall PyObject_GetAttrString();                          
int __declspec(dllexport) __stdcall PyErr_Clear();                                      
int __declspec(dllexport) __stdcall PyCallable_Check();                               
int __declspec(dllexport) __stdcall PyObject_CallObject();                        
int __declspec(dllexport) __stdcall PyErr_Print();                                 
int __declspec(dllexport) __stdcall PyString_Type();                                   
int __declspec(dllexport) __stdcall PyString_AsString();                        
int __declspec(dllexport) __stdcall PyFloat_AsDouble();                            
int __declspec(dllexport) __stdcall _Py_NoneStruct();                                
int __declspec(dllexport) __stdcall PyErr_BadArgument();                           
int __declspec(dllexport) __stdcall PyList_New();                                
int __declspec(dllexport) __stdcall PyString_FromString();                                
int __declspec(dllexport) __stdcall PyList_Append();                                    
int __declspec(dllexport) __stdcall PyTuple_Type();                                       
int __declspec(dllexport) __stdcall PyInt_AsLong();                                      
int __declspec(dllexport) __stdcall PyString_InternFromString();                          
int __declspec(dllexport) __stdcall Py_Finalize();
int __declspec(dllexport) __stdcall PyExc_RuntimeError();                           
int __declspec(dllexport) __stdcall PyErr_SetString();                                
int __declspec(dllexport) __stdcall PyTuple_GetItem();                                   
int __declspec(dllexport) __stdcall PyDict_Type();                                  
int __declspec(dllexport) __stdcall PyType_IsSubtype();                            
int __declspec(dllexport) __stdcall PyDict_GetItemString();                        
int __declspec(dllexport) __stdcall PyLong_AsLong();                           
int __declspec(dllexport) __stdcall PyTuple_Size();                                  
int __declspec(dllexport) __stdcall Py_InitModule4();                                      
int __declspec(dllexport) __stdcall PyModule_AddIntConstant();                            
int __declspec(dllexport) __stdcall Py_BuildValue();      
};
python22.cpp:
Code:
#include "stdafx.h"
#include "exports.h"


/*****************************************************
************ Liste der nötigen Exports ***************
******************************************************
------------------------------------------------------
++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++ ITEMS: 38 ++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++
----------------------------------------------------*/
extern "C"
{
int __declspec(dllexport) __stdcall Py_SetProgramName() { return 0; }                                   
int __declspec(dllexport) __stdcall PyImport_AddModule() { return 0; }                                   
int __declspec(dllexport) __stdcall PyModule_GetDict() { return 0; }                                     
int __declspec(dllexport) __stdcall PyImport_ImportModule() { return 0; }                                
int __declspec(dllexport) __stdcall PyDict_SetItemString() { return 0; }                                 
int __declspec(dllexport) __stdcall PyRun_String() { return 0; }                                         
int __declspec(dllexport) __stdcall Py_Initialize() { return 0; }                                        
int __declspec(dllexport) __stdcall PyErr_Fetch() { return 0; }                                          
int __declspec(dllexport) __stdcall PyNumber_Check() { return 0; }                                       
int __declspec(dllexport) __stdcall PyObject_GetAttr() { return 0; }                                     
int __declspec(dllexport) __stdcall PyObject_GetAttrString() { return 0; }                               
int __declspec(dllexport) __stdcall PyErr_Clear() { return 0; }                                          
int __declspec(dllexport) __stdcall PyCallable_Check() { return 0; }                                     
int __declspec(dllexport) __stdcall PyObject_CallObject() { return 0; }                                  
int __declspec(dllexport) __stdcall PyErr_Print() { return 0; }                                          
int __declspec(dllexport) __stdcall PyString_Type() { return 0; }                                        
int __declspec(dllexport) __stdcall PyString_AsString() { return 0; }                                    
int __declspec(dllexport) __stdcall PyFloat_AsDouble() { return 0; }                                     
int __declspec(dllexport) __stdcall _Py_NoneStruct() { return 0; }                                       
int __declspec(dllexport) __stdcall PyErr_BadArgument() { return 0; }                                    
int __declspec(dllexport) __stdcall PyList_New() { return 0; }                                           
int __declspec(dllexport) __stdcall PyString_FromString() { return 0; }                                  
int __declspec(dllexport) __stdcall PyList_Append() { return 0; }                                        
int __declspec(dllexport) __stdcall PyTuple_Type() { return 0; }                                         
int __declspec(dllexport) __stdcall PyInt_AsLong() { return 0; }                                        
int __declspec(dllexport) __stdcall PyString_InternFromString() { return 0; }                            
int __declspec(dllexport) __stdcall Py_Finalize() { return 0; }                                          
int __declspec(dllexport) __stdcall PyExc_RuntimeError() { return 0; }                                   
int __declspec(dllexport) __stdcall PyErr_SetString() { return 0; }                                      
int __declspec(dllexport) __stdcall PyTuple_GetItem() { return 0; }                                      
int __declspec(dllexport) __stdcall PyDict_Type() { return 0; }                                          
int __declspec(dllexport) __stdcall PyType_IsSubtype() { return 0; }                                     
int __declspec(dllexport) __stdcall PyDict_GetItemString() { return 0; }                                 
int __declspec(dllexport) __stdcall PyLong_AsLong() { return 0; }                                        
int __declspec(dllexport) __stdcall PyTuple_Size() { return 0; }                                         
int __declspec(dllexport) __stdcall Py_InitModule4() { return 0; }                                       
int __declspec(dllexport) __stdcall PyModule_AddIntConstant() { return 0; }                              
int __declspec(dllexport) __stdcall Py_BuildValue() { return 0; }                                        
}
dllmain.cpp:
Code:
#include "stdafx.h"
#include "exports.h"
#include "windows.h"
#include "dll.h"

#ifdef _MANAGED
#pragma managed(push, off)
#endif

HMODULE lib = 0;

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
					 )
{ 
   switch ( ul_reason_for_call ) {
    case DLL_PROCESS_ATTACH:
      lib = LoadLibraryA("python22_original.dll");
      // MAIN THREAD!!!
      break;
    case DLL_PROCESS_DETACH:
      FreeLibrary(lib);
      break;
  }
  return TRUE;
}


#ifdef _MANAGED
#pragma managed(pop)
#endif