|
Posted by bg-greece on October 26, 2005, 2:06 pm
Please log in for more thread options
You mean I should create the DLL with cygwin/gcc?
Putting aside that it needs a lot of time to do the porting, it contradicts
the fact that I can perfectly call Windows system DLL's like user32,
kernel32 and so on using Win32::API.
B.
>
> >> Just a very wild guess: you wrote Cygwin. How did you make the DLL?
> >> Inside Cygwin, or outside it?
>
> > the dll was created with with Microsoft Visual C++ 6.0
>
> That might cause the problem(s) you see.
>
> --
> John Small Perl scripts: http://johnbokma.com/perl/
> Perl programmer available: http://castleamber.com/
> I ploink googlegroups.com :-)
>
|
|
Posted by harryfmudd [AT] comcast [DOT] on October 26, 2005, 10:45 am
Please log in for more thread options
bg-greece wrote:
> You mean I should create the DLL with cygwin/gcc?
> Putting aside that it needs a lot of time to do the porting, it contradicts
> the fact that I can perfectly call Windows system DLL's like user32,
> kernel32 and so on using Win32::API.
Well, to be honest I have never done what you're trying to do FROM
CYGWIN. I also note that someone has, because Win32-Process-Info 1.006
has a "pass" from Cygwin (see
http://testers.cpan.org/show/Win32-Process-Info.html).
On the other hand, if you have the calling sequence right (as you say
you do) and if the version of C doesn't matter (as you say it doesn't),
then we just proved your code works.
But it doesn't. At this point, I generally ask myself "what is it that I
know to be true, but which is in fact not true?". The possibilities seem
to me to be:
1) the calling sequence is in fact coded incorrectly in Perl. I have no
experience with the prototype version of the interface, but the
traditional interface call in Bart Lateur's response looks right to me
given the C signature in your original note, and you say that didn't work.
2) Different compilers _can_ produce different calling sequences, so
that's what I was focusing on. You say calls to Kernel32 work, which
suggests that this isn't the problem, but doesn't prove it, since we
don't know that Kernel32 was written in Visual C++. But we _do_ know
that Visual C++ can call kernel32.dll. Have you read kernel32.h, and
made sure your signatures are specified the same way? C++ wants to
mangle function names (that's how overloading works), and it's possible
that there is more than one way to handle the call stack. A mangled
function name would probably result in a failure to import the function,
but there are probably other things that could go wrong.
3) Something else entirely. Arthur Conan Doyle was wrong when he had
Sherlock Holmes say something like "When you have eliminated everything
else, the remaining possibility, however improbable, must be the truth."
The problem with the Sherlock Holmes approach is that it assumes you
really know what every single possibility is.
Tom Wyant
|
|
Posted by Bart Lateur on October 25, 2005, 10:34 am
Please log in for more thread options
bg-greece wrote:
>I am using cygwin and perl and trying to access some function from a C++
>windows dll. After the first attempt produced a segmentation fault, I tried
>to do it step-by-step. I created a dummy function in the dll file:
>
>int TestDLL(int x)
>{
> return 1;
>}
>
>
>and put the following code in a perl file:
>
>use strict;
>use Win32::API::Prototype;
>
>my $TestDLL = ApiLink("mydll",'I TestDLL(I x)');
> if (not defined $TestDLL) {
> die "Can't import API TestDLL: $! \n";
>}
In my experience, the prototype based stuff is very buggy. I've had
nothing but crashes with it. I would skip it and go the oldfashioned raw
way, which always *did* work. Try.
use Win32::API;
my $TestDLL = Win32::API->new('mydll', 'TestDLL', 'I', 'I')
or die "Can't load function";
HTH,
Bart.
|
|
Posted by bg-greece on October 25, 2005, 3:42 pm
Please log in for more thread options
In fact Win32::API was the first try and it also produced segmentation
fault.Other trivial examples however (with kernel32.dll for example) have
worked.
> In my experience, the prototype based stuff is very buggy. I've had
> nothing but crashes with it. I would skip it and go the oldfashioned raw
> way, which always *did* work. Try.
>
> use Win32::API;
> my $TestDLL = Win32::API->new('mydll', 'TestDLL', 'I', 'I')
> or die "Can't load function";
>
> HTH,
> Bart.
|
|
Posted by Sisyphus on October 30, 2005, 9:49 am
Please log in for more thread options
> In fact Win32::API was the first try and it also produced segmentation
> fault.Other trivial examples however (with kernel32.dll for example) have
> worked.
>
Those dll's that are working were built using the stdcall calling
convention. I suggest building your dll using the same calling convention -
there's a command line switch that does that for you. (I think it's '/Gz' -
but check 'cl /?')
There exists somewhere a patched version of Win32::API that will work with
cdecl calling convention, but I don't think that patched version has been
ported to Cygwin.
Cheers,
Rob
|
| Similar Threads | Posted | | Perl under MS IIS with access to MySQL | June 19, 2005, 11:24 pm |
| pure-perl access to mySQL | June 14, 2005, 8:38 am |
| new module Logfile::Access | October 23, 2004, 8:30 pm |
| Announce: Win32::SqlServer - access SQL Server from Perl | November 27, 2005, 5:03 pm |
| Module to use for win32 registry access? | April 4, 2007, 8:32 pm |
| XP, Perl, Win32::ODBC, Microsoft Access 2002 SP3, & Chinese characters | January 22, 2008, 4:18 pm |
| Do Win32::ODBC module support Chinese characters when used with MS Access? | September 15, 2004, 10:33 pm |
| Microsoft Access & Win32::Ole | October 28, 2005, 4:03 pm |
| Access DOM using JavaScript::SpiderMonkey | January 16, 2006, 12:37 pm |
| compiling/add modules when no root access | March 22, 2006, 4:21 pm |
|