$pass = $pass && defined($CreateTable->Call()) == 1;
You probably leaked a table. Do doing the Call() means you run the C function and the defined check is meaningless since the result will be 0 (probably NULL pointer/failure for the C function) or a pointer (12345 format), never undefined. Check defined only on $CreateTable API obj. I posted code from a test suite of Win32::API, you need to change it a little bit more.
$aTable = $CreateTable->Call(); print("Table Created");
Correct, try printing $aTable to the screen, I prefer Data::Dumper.
use Data::Dumper; $Data::Dumper::Useqq = 1; print Dumper($aTable);
$aTable should be a decimal number, 123456 style. "HANDLER" isn't a C or Win32 API type. Its "HANDLE". If you tried HANDLER you should be getting warnings printed to console, but I'm not sure if 0.68 will report unknown types or not.
About the whole packing and unpacking of the handlers before passing them out, I'm not sure whether I should pack $aTable or not. I understand that because it's the value returned by an API function, $aTable should already be stored with the appropiate format (unless there is any transformation behind the scenes before perl stores its value).
"appropiate format", no its not. Thats why 0.68 sucks.
I have packed the string with the file path since in the header files it's advised that the string containing the filename has to be null terminated (I've checked http://perldoc.perl.org/functions/pack.html and sounds like a pack('Z', string) to me).
Useless, all scalar strings in perl are automatically null terminated at all times secretly so they can be passed to OS/library C function that want null terminated (even if you feed binary garbage to the C function, the C function will hit a null in your binary garbage, or hit the secret null, either way, it will never buffer overflow. This is a ansi/ascii null, not a UTF16 null, if your doing UTF16 in perl, you need to write "\x00\x00" yourself. The secret null character never appears in the perl language, so if you put the scalar to disk, or through a network, then you need to add the null yourself with pack or
.= "\x00";
Something isn't right since I get a "Segmentation fault (core dumped)" error. Which means I'm not passigng the correct arg for LPHANDLER raw_result. I've tried to "$aTable=pack('J',$aTable);" before passing it to myTableLoadfromFile, but I still get the same error. Any idea what I'm missing?
The pack J is what your missing. After you pack $aTable, do a print Dumper on it, it should be 4 or character, some of the characters might be in "\123" octal escape sequence since they are unprintable binary. You can also try
$packedaTable = pack('J', $aTable); die "bad code" if unpack('J', $packedaTable) != $aTable;
you can also scrap the C prototype interface of Win32 API and use the letter interface.
my $LoadTableFromFile = new Win32::API("myDll.dll","int myTableLoadFro +mFile(char* filename, LPHANDLE raw_result)");
becomes
my $LoadTableFromFile = new Win32::API("myDll.dll", "myTableLoadFromFi +le", 'PP', 'I');
Final question, are you on 32 bits or 64 bit windows and what is the calling convention of your C functions? I think you have cdecl functions, since a no parameter stdcall and a no parameter cdecl are interchangable and identical under the hood, so whats might be why create doesn't crash, but myTableLoadFromFile does.

Regarding the pack J, you can't remove it. Reread my last post, your forgetting the difference between a HANDLE and a LPHANDLE on API 0.68.

In reply to Re^5: WIN32::API and void* by bulk88
in thread WIN32::API and void* by sgv_81

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.