"External function not found" using PokeLSString alias memcpy

Hi,

we’ve just made an upgrade from R5 to R8.5 and we have a problem with a scheduled agent

here’s an exemple to reproduce the error message

i tried memcpy and the new secure version memcpy_s but no way

Option Public

Option Declare

Declare Private Sub PokeLSString Lib “MSVCRT” Alias “memcpy” ( D As Long, Byval S As String, Byval C As Long)

Declare Private Sub PokeLSStringS Lib “MSVCRT” Alias “memcpy_s” ( D As Long, Byval N As Long, Byval S As String, Byval C As Long)

Sub Initialize

On Error Goto erreur



Dim Text(1023) As Long

Dim header As String

Dim size As Integer



header = "toto"

size = Len(header)



PokeLSString Text(0), header, Clng(Size)

PokeLSStringS Text(0), 1024,header, Clng(Size)





Exit Sub

erreur:

Print Error$ & " ligne " & Erl()

Resume Next

Exit Sub

End Sub

any idea?

Subject: Explanation

This is not an issue w/ 8.5. Its also a problem on previous versions w/ this code. The function memcpy_s is not externalized in the version of msvcrt, so the declare statement cannot find it at runtime and throws the “External function not found” error. We would recommend that you use the WinDbg debugger’s x command to verify this, by attaching a debugger to a process (could be anything like notepad or Notes), and issuing the command:

X msvcrt!mem*

This yields the output:

77c46170 msvcrt!memccpy ()

77c461c8 msvcrt!memicmp ()

77c46e00 msvcrt!memchr ()

77c46eb0 msvcrt!memcmp ()

77c46f70 msvcrt!memcpy ()

77c472b0 msvcrt!memmove ()

77c475f0 msvcrt!memset ()

If we remove your use of the memcpy_s function the error goes away. You should determine what library this memcpy_s function is located in.

Subject: Thanks

ok, this function was used in a script for creating html emails, I’ll try another way to do it.

NotesMIMEEntity maybe?