Post by jeeswg » 26 May 2018, 04:59
YES. OK Helgef, here we are.
As you imply, if I comment out the AStr line, I get the 52 for the other lines that I was expecting.
AStr is *modifying* the string.
Hmm, it's a surprise that AStr is modifying the string, however!
I had thought that AHK would create a temporary variable based on vText, and pass that, leaving vText untouched.
(So perhaps you don't need to change your explanation. I'll give it a reread.)
Code: Select all
;MsgBox, % DllCall(stringlen, "AStr",vText, "Cdecl") ;26 ;if this line is called, the next 3 lines return 1
MsgBox, % DllCall(stringlen, "WStr",vText, "Cdecl") ;52
MsgBox, % DllCall(stringlen, "Str",vText, "Cdecl") ;52
MsgBox, % DllCall(stringlen, "Ptr",&vText, "Cdecl") ;52
MsgBox, % DllCall(stringlen2, "AStr",vText, "Cdecl") ;13
MsgBox, % DllCall(stringlen2, "WStr",vText, "Cdecl") ;26
MsgBox, % DllCall(stringlen2, "Str",vText, "Cdecl") ;26
MsgBox, % DllCall(stringlen2, "Ptr",&vText, "Cdecl") ;26
It's nice to know that my 4th stringedit function works for you, but I can't think why it isn't working for me. Could you post the machine code that you're getting? And/or check the code below. Thanks.
Code: Select all
q:: ;test byte write
vSize := 255
VarSetCapacity(vData, vSize, 0)
vFunc := MCode("2,x86:i0QkBGYPbwUAAAAAxkAQEMZAEREPEQDGQBISxkATE7gUAAAAw5CQkJCQkJCQkJCQAAECAwQFBgcICQoLDA0ODw==,x64:Zg9vBQAAAAC4FAAAAMZBEBDGQRERDxEBxkESEsZBExPDkJCQkJCQkJCQkJCQkJCQAAECAwQFBgcICQoLDA0ODw==")
MsgBox, % DllCall(vFunc, "Ptr",&vData, "Cdecl")
vOutput := ""
Loop, % vSize
vOutput .= (A_Index=1?"":",") NumGet(&vData, A_Index-1, "UChar")
MsgBox, % vOutput
return
/*
int stringedit(char *str)
{
int i=0;
for (; i<20; i++)
str[i]=i;
return i;
}
*/
YES. OK Helgef, here we are.
As you imply, if I comment out the AStr line, I get the 52 for the other lines that I was expecting.
AStr is *modifying* the string.
Hmm, it's a surprise that AStr is modifying the string, however!
I had thought that AHK would create a temporary variable based on vText, and pass that, leaving vText untouched.
(So perhaps you don't need to change your explanation. I'll give it a reread.)
[code]
;MsgBox, % DllCall(stringlen, "AStr",vText, "Cdecl") ;26 ;if this line is called, the next 3 lines return 1
MsgBox, % DllCall(stringlen, "WStr",vText, "Cdecl") ;52
MsgBox, % DllCall(stringlen, "Str",vText, "Cdecl") ;52
MsgBox, % DllCall(stringlen, "Ptr",&vText, "Cdecl") ;52
MsgBox, % DllCall(stringlen2, "AStr",vText, "Cdecl") ;13
MsgBox, % DllCall(stringlen2, "WStr",vText, "Cdecl") ;26
MsgBox, % DllCall(stringlen2, "Str",vText, "Cdecl") ;26
MsgBox, % DllCall(stringlen2, "Ptr",&vText, "Cdecl") ;26
[/code]
It's nice to know that my 4th stringedit function works for you, but I can't think why it isn't working for me. Could you post the machine code that you're getting? And/or check the code below. Thanks.
[code]
q:: ;test byte write
vSize := 255
VarSetCapacity(vData, vSize, 0)
vFunc := MCode("2,x86:i0QkBGYPbwUAAAAAxkAQEMZAEREPEQDGQBISxkATE7gUAAAAw5CQkJCQkJCQkJCQAAECAwQFBgcICQoLDA0ODw==,x64:Zg9vBQAAAAC4FAAAAMZBEBDGQRERDxEBxkESEsZBExPDkJCQkJCQkJCQkJCQkJCQAAECAwQFBgcICQoLDA0ODw==")
MsgBox, % DllCall(vFunc, "Ptr",&vData, "Cdecl")
vOutput := ""
Loop, % vSize
vOutput .= (A_Index=1?"":",") NumGet(&vData, A_Index-1, "UChar")
MsgBox, % vOutput
return
/*
int stringedit(char *str)
{
int i=0;
for (; i<20; i++)
str[i]=i;
return i;
}
*/
[/code]