X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Message-ID: <18626165.post@talk.nabble.com> Date: Wed, 23 Jul 2008 23:38:17 -0700 (PDT) From: Stefano Facchetti To: cygwin AT cygwin DOT com Subject: RE: Cygwin dll from C# Application In-Reply-To: <003a01c8ecf0$5a00fee0$9601a8c0@CAM.ARTIMI.COM> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: s DOT facchetti AT kline DOT it References: <18616035 DOT post AT talk DOT nabble DOT com> <48877048 DOT B7BFB5F AT dessent DOT net> <18616996 DOT post AT talk DOT nabble DOT com> <003a01c8ecf0$5a00fee0$9601a8c0 AT CAM DOT ARTIMI DOT COM> X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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 #include #include 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 #include #include #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/