Following the tutorial, I modify my code.. But when I call a dll method from C# application, it immediatly freeze.
Here the code: faddll.h #include <string> #include <map> #include <vector> namespace cygwin { class padding { public: padding (); ~padding (); private: std::vector< char > _backup; char *_stackbase, *_end; char _padding[4096]; static padding *_main; static DWORD _mainTID; }; } faddll.cc #include <stdio.h> #include <windows.h> #include <faddll.h> #define DllExport extern "C" __declspec(dllexport) cygwin::padding *cygwin::padding::_main = NULL; DWORD cygwin::padding::_mainTID = 0; static std::ostream *out = NULL; cygwin::padding::padding () { _main = this; _mainTID = GetCurrentThreadId (); _end = _padding + sizeof (_padding); char *stackbase; #ifdef __GNUC__ __asm__ ( "movl %%fs:4, %0" :"=r"(stackbase) ); #else __asm { mov eax, fs:[4]; mov stackbase, eax; } #endif _stackbase = stackbase; if ((_stackbase - _end) != 0) { size_t delta = (_stackbase - _end); _backup.resize (delta); memcpy (&(_backup[0]), _end, delta); } } cygwin::padding::~padding () { _main = NULL; if (_backup.size ()) { memcpy (_end, &(_backup[0]), _backup.size ()); } } DllExport int Somma(int a,int b); int Somma(int a, int b) { cygwin::padding padding; HMODULE h = LoadLibrary("cygwin1.dll"); void (*init)() = (void(*)()) GetProcAddress(h,"cygwin_dll_init"); init(); return a+b; } Dave Korn wrote: > > The path refers to a location in the sourceware.org CVS repository. You > could check out the winsup module using CVS, you could use setup.exe to > install the source for your current version of the Cygwin dll and look for > it there, or you can just browse it through the sourceware.org cvsweb > interface, at: > > http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/cygwin/how-cygtls-works.txt? > cvsroot=src > -- View this message in context: http://www.nabble.com/Cygwin-dll-from-C--Application-tp18616035p18626165.html Sent from the Cygwin list mailing list archive at Nabble.com. -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/