Mail Archives: cygwin/1997/03/22/07:04:40
John Cerney wrote:
>
> When running, the thing crashes when the DLL function is called. An
access
> violation occurs in cygwin.dll. The foo.dll that is built uses cygwin.dll
for
> its printf function. If I take the printf out of the foo.dll code the
VC++
> main2.exe will run just fine.
>
This problem is due to struct reent_data in a dll and pointer to it
(_impure_ptr) remains uninitialized after dll loading. The patch below
solves this problem. This patch moves reent_data from application's private
address space to cygwin.dll and adds pointer to this structure to
cygwin.dll export table. Auto-initialisation code of your dll now can
initialize _impure_ptr properly. Also, this patch modifies fork() code to
copy contents of parent's reent_data to the child. Allpy this patch (it
modifies files dcrt0.cc, fork.cc and winsup.h), add "reent_data" to export
list in cygwin.din, and rebuild cygwin.dll. Add the following file to your
dll:
#include <windows.h>
#include <stdio.h>
extern struct _reent *_impure_ptr,
*__imp_reent_data;
int WINAPI dll_main(HANDLE a, DWORD reason, void *q)
{
switch (reason){
case DLL_PROCESS_ATTACH: break;
case
DLL_PROCESS_DETACH: break;
case DLL_THREAD_ATTACH: break;
case
DLL_THREAD_DETACH: break;
};
_impure_ptr=__imp_reent_data;
return
1;
}
main(){}
and build your dll (I've used three-pass method as for cygwin.dll). Ld's
command line should contain "-e _dll_main AT 12".
--
Sergey Okhapkin
Moscow, Russia
Looking for a job
begin 600 dll.diff
M*BHJ(&1C<G0P+F-C"51U92!&96(@,#0@,#<Z,#<Z,#,@,3DY-PHM+2T AT 93ID
M8W)T,"YC8PE4:'4 AT 36%R(#(P(#(R.C$U.C0R(#$Y.3<**BHJ*BHJ*BHJ*BHJ
M*BHJ"BHJ*B S,BPS-R J*BHJ"BTM+2 S,BPS." M+2TM"B @("!C:&%R("HJ
M96YV:7)O;CL*(" @("\J(%]?<')O9VYA;64@=7-E9"!I;B!G971O<'0 AT 97)R
M;W(@;65S<V%G92 J+PH@(" @8VAA<B J7U]P<F]G;F%M93L**R @('-T<G5C
M="!?<F5E;G0@<F5E;G1?9&%T83L*("!].PH@( H@('-T871I8R!C;VYS="!I
M;G0 AT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M9BP@>"P@=2T^<V5L9BT^<'!I9"D["B @"BHJ*B!W:6YS=7 N:"YO<FEG"49R
M:2!&96(@,30@,#$Z,#$Z,3D@,3DY-PHM+2T@=VEN<W5P+F@)5&AU($UA<B R
M," Q-SHP,SHR-R Q.3DW"BHJ*BHJ*BHJ*BHJ*BHJ*@HJ*BH@,C,X+#(T,R J
M*BHJ"BTM+2 R,S AT L,C0T("TM+2T*(" *(" @("\J($]P96X AT 9FEL92!T86)L
M92X@*B\*(" @(&AI;F9O7W9E8R!H;6%P.PHK(" @<W1R=6-T(%]R965N="!R
M965N=%]S879E.PH@( H@(" @<W1R=6-T('-I9V%C=&EO;B!S:6=S6TY324==
M.PH@(" @<VEG<V5T7W0@<VEG7VUA<VL["0DO*B!O;F4@<V5T(&9O<B!E=F5R
5>71H:6YG('1O(&EG;F]R92X@*B\*
`
end
-
For help on using this list, send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".
- Raw text -