AutoHotkey Community
Let's help each other out
Skip to content
Post by Helgef » 27 May 2018, 03:32
- I'm yet to have any problems with C/C++ I've got enough knowledge now to do some good codes.
isn't it equally correct to say that we should edit the hex string for the machine code.
it looks like we need to know a bit about ASM
nnnik wrote:This is just the beginning of issues.
Post by nnnik » 26 May 2018, 22:38
Post by jeeswg » 26 May 2018, 18:07
Post by Helgef » 26 May 2018, 17:29
Post by nnnik » 26 May 2018, 12:21
Post by jeeswg » 26 May 2018, 11:50
nnnik wrote:Well I guess I never mentioned that you need to use VarSetCapacity to initialize data in them then.
Post by nnnik » 26 May 2018, 11:44
Post by jeeswg » 26 May 2018, 11:16
Post by Helgef » 26 May 2018, 07:35
Post by jeeswg » 26 May 2018, 07:35
Post by nnnik » 26 May 2018, 07:31
Post by jeeswg » 26 May 2018, 07:29
Post by nnnik » 26 May 2018, 07:25
Post by jeeswg » 26 May 2018, 07:20
Post by Helgef » 26 May 2018, 07:05
So it worked for you didn't it?
Post by jeeswg » 26 May 2018, 06:50
Helgef wrote:It works as I expect, it returns 20 and initialises the char array as: 0, 1 ... 19
Post by Helgef » 26 May 2018, 06:23
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.
dllcall -> str wrote: A string such as "Blue" or MyVar. If the called function modifies the string and the argument is a naked variable, its contents will be updated. For example, the following call would convert the contents of MyVar to uppercase: DllCall("CharUpper", "Str", MyVar).
I can't think why it isn't working for me
Post by jeeswg » 26 May 2018, 04:59
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
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; } */
Post by Helgef » 26 May 2018, 03:30
// didn't work
Apologies but I still don't see an explanation for the problem.
jeeswg wrote:- If you could create a version of the stringlen function that works with Ptr, that might help to comprehend the situation better. Thanks.
Post by nnnik » 25 May 2018, 23:28
Top