Sign in to follow this  
Followers 0
ADMPV

passing file pointer to c dll in dllcall

3 posts in this topic

#1 ·  Posted

in calls to winapi file handle passes as HANDLE and all ok.

but in plain C it may be FILE*

ex:

RHASH_API void rhash_run_benchmark(unsigned hash_id, unsigned flags,
                   FILE* output);


calls like

  Local $aResult = DllCall("librhash.dll", "none:cdecl", "rhash_run_benchmark", _
    "uint", $hash_id, _
    "uint", $flags, _
    "handle", $output)

crashes

(i try handle, handle*, ptr, ptr*, hwnd, hwnd*, ....)

may be someone know solution ?

Share this post


Link to post
Share on other sites



#2 ·  Posted

sizeof(FILE*) == 4

Share this post


Link to post
Share on other sites

#3 ·  Posted

the solution is modify source c dll code (write wrapper c func)

like this

void rhash_run_benchmark_mod(unsigned hash_id, unsigned flags, const char* output)
{
    FILE* f = fopen(output, "wb");
    rhash_run_benchmark(hash_id, flags, f);
        fclose(f);
}

not the case if no source code for dll :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0