* another LoadLibrary question / crash (sorry)
@ 2015-12-04 19:25 Mike Giancola
0 siblings, 0 replies; only message in thread
From: Mike Giancola @ 2015-12-04 19:25 UTC (permalink / raw)
To: cygwin
Hi,
I apologize for asking the same question that has been asked so many
times - but I'm stuck.
I have a DLL built in Cygwin that I'm trying to call from a program
compiled in Visual Studio 2012. When I call LoadLibrary it's
successful, however calls to the APIs crash the program.
From what I've read, I understand I need to allocate "4k of scratch
space at the bottom of the stack" and call the cygwin_dll_init first.
(From https://cygwin.com/faq/ section 6.19).
I haven't been able to find the how-cygtls-works.txt nor
winsup/testsuite/cygload - most of the links in old mail archives are
dead (some messages go back to 2007). That said, I've found cygload.cc
here: https://raw.githubusercontent.com/openunix/cygwin/master/winsup/testsuite/winsup.api/cygload.cc
Here, the code attempts to use some assembly to set the stack size:
#ifdef __GNUC__
__asm__ (
"movl %%fs:4, %0"
:"=r"(stackbase)
);
#else
__asm
{
mov eax, fs:[4];
mov stackbase, eax;
}
#endif
However these lines crash the program. I've downloaded these exact
files (the .cc & .h) and compiled them using VS2012. When debugged /
run i get an access violation and crash. Note - i'm trying to run this
program as is, unmodified.
Is there a specific compiler flag i need to set in order to allow
these operations? I've turned off DEP, i've tried both set the entry
point to be cygloadCRTStartup then going back - reseting the entry
point and uncommenting the construction of the padding object line.
Both fail.
Does anyone happen to have a simple example - simply calling a
"fooapi" within a dll available? Is there any updated documentation
anywhere?
Thanks for the help!
mike
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-12-04 19:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-04 19:25 another LoadLibrary question / crash (sorry) Mike Giancola
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).