Sign in to follow this  
Followers 0
wraithdu

memcpy, memset help

6 posts in this topic

Why on earth is this crashing under Vista?

Func _memset($dest, $c, $size)
    Local $ret = DllCall("msvcrt.dll", "ptr", "memset", "ptr", $dest, "int", $c, "long", $size)
    Return $ret[0]
EndFunc

$s = DllStructCreate("char[10]")
_memset(DllStructGetPtr($s), 58, DllStructGetSize($s))

Thanks...I'm tired :)

Share this post


Link to post
Share on other sites



Ok, so I can write AutoIt versions of memcpy and memset, however I need to get realloc working. Again, same crash -

Func _realloc($src, $size)
    Local $ret = DllCall("msvcrt.dll", "ptr", "realloc", "ptr", $src, "long", $size)
    Return $ret[0]
EndFunc

$s = DllStructCreate("char[10]")

$ret = _realloc(DllStructGetPtr($s), DllStructGetSize($s))
ConsoleWrite($ret & @CRLF)

Share this post


Link to post
Share on other sites

The functions in msvcrt.dll uses the cdecl calling convention.


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks! Sheesh, how did you know that? Just experience?

Oh, and I guess realloc doesn't work with DllStruct pointers, only pointers from malloc / calloc.

Edited by wraithdu

Share this post


Link to post
Share on other sites

Thanks! Sheesh, how did you know that? Just experience?

Oh, and I guess realloc doesn't work with DllStruct pointers, only pointers from malloc / calloc.

I checked the C++ header.


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

So this would be it, then?

void * __cdecl realloc(_In_opt_ void * _Memory, _In_ size_t _NewSize);

Good to know. Thanks again.

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