-
Posts
409 -
Joined
-
Last visited
-
Days Won
4
Everything posted by AndyG
-
TimerDiff returns with very large offset
AndyG replied to Balthamel's topic in AutoIt General Help and Support
@Simpel (was ein Name... :o) ) habe die erste Zeile vergessen zu kopieren , did lost the first line while copy/paste #AutoIt3Wrapper_UseX64=n ;32-Bit mode (original code in post#11 edited) -
TimerDiff returns with very large offset
AndyG replied to Balthamel's topic in AutoIt General Help and Support
Hi, there is a correlation between the Clockticks of the CPU (can be read by RDTSC) and the Autoit-TimerInit()-Function.... ;RDTSC returns the clockticks since computer start in EDX:EAX $struct = DllStructCreate("byte[3]") ;reserve memory DllStructSetData($struct, 1, "0x0F31C3") ;RDTSC and RET into memory ;testroutine correlation between RDTSC and TimerInit() $ret = DllCallAddress("uint:cdecl", DllStructGetPtr($struct)) ;call memory returns colockticks in EAX $rdtsc_old = $ret[0] ;get clockticks in EAX $t_old = TimerInit() For $i = 1 To 10 $ret = DllCallAddress("uint:cdecl", DllStructGetPtr($struct)) ;call memory returns clockticks in EAX $t = TimerInit() $rdtsc = $ret[0] ;get clockticks in EAX ConsoleWrite("delta RDTSC = " & Int(($rdtsc - $rdtsc_old) / 1000) & @CRLF) ;difference RDTSC ConsoleWrite("delta Timer = " & $t - $t_old & @CRLF & @CRLF) ;difference TimerInit() $rdtsc_old = $rdtsc $t_old = $t Next -
Hi, The question is, what do you want to do? Nobody reads 140MB data to display them within an _ArrayDisplay()! Some profiling shows that reading a 169MB testfile takes about 4 seconds, regex takes 6 seconds, transforming 1D_>2D-array takes 17 seconds....all in all 27 seconds on my machine (without "showing" the data via _ArrayDisplay() which takes 8-10 extra seconds) How should the data be further processed? I am almost sure that there is a faster solution for your "real" problem...
-
Stringregexp get recurrent match between html tags
AndyG replied to Kyan's topic in AutoIt General Help and Support
Hi, #include<array.au3> $aPreDATA = '<div data-type="inputText" name="title" data-multilang data-legend="Título" data-force><pt_pt>ALLWORK</pt_pt><en_gb>ALLWORK</en_gb><fr_fr>ALLWORK</fr_fr><de_de>ALLWORK</de_de></div>' $atitle = StringRegExp($aPreDATA,'(?i)(\w{2}_\w{2})>(.+?)<\/\g1>',3) _ArrayDisplay($atitle) -
#include <Misc.au3> _singleton()
-
Mixed binary and ASCII file - want to read ASCII
AndyG replied to fopetesl's topic in AutoIt General Help and Support
Hi, I do not know which Scite version you are using, In all Scite versions which i have used since 2008, the CTRL+SHIFT+D writes a line with a DEBUG-Msgbox whith the content of a variable or function the cursor stands on (or a marked funktion or anything else). ALT+D writes a DEBUG-consolewrite. In the "extras" Menu you will find some more very(!) helpful commands and shortcuts to debug your code within seconds. I think 80% of the "help me"-posts in every internet-(programming)-forum could be avoided with minimalistic usage of simplest debugging functions! -
Mixed binary and ASCII file - want to read ASCII
AndyG replied to fopetesl's topic in AutoIt General Help and Support
Hi, StringInstr() returns the position of the substring, your parameter "4" returns the 4th occurrence of the substring.... You should better use MUCH more of CTRL+SHIFT+D and ALT+D.... -
could be done this way... #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include-once #include <WinAPISys.au3> ;========================================================================================== $tagInfo = "struct;HWND hMainHandle;WORD iID;WCHAR Line[512];endstruct" ;========================================================================================== $ptrInfo = Ptr($CmdLine[1]) $sizeInfo = Int($CmdLine[2]) $tInfo = DllStructCreate($tagInfo) $tptr=dllstructgetptr($tinfo) $tsize=DllStructGetSize($tinfo) If @error Then MsgBox(64,"DllStructCreate",@error) $pid=Processwait("Script_A.exe") $process = _WinAPI_OpenProcess(0xFFFF, False, $pid) $bytes=0 $a=_WinAPI_ReadProcessMemory($process,$ptrInfo,$tptr,$tsize,$bytes) MsgBox(64,"Script_B.1", "Struct Pointer : " & Ptr($CmdLine[1])& @CRLF & _ "IsPtr() = " & IsPtr($ptrInfo)& @CRLF & _ "Struct Size = " & $sizeInfo & @CRLF & _ "_WinAPI_IsBadReadPtr() = " & _WinAPI_IsBadReadPtr($ptrInfo, $sizeInfo) & @CRLF & _ "_WinAPI_IsBadWritePtr() = " & _WinAPI_IsBadWritePtr($ptrInfo, $sizeInfo)) MsgBox(64,"Script_B.2", "String Recieved : " & $tInfo.Line) Exit
-
Show your scripts, the call of a dll has nothing to to with TLB. Compile this script, start it several times. You will see a "counter" running, each for its own process/window. You can stop the counter while holding the upper frame/border of the corresponding window. After release, the counter continues. After a click of ONE of the "Reset/sync"-Button, the counter of ALL Processes/windows will reset... sharedmemdll.zip
-
Yes, i know. But...the question was, why do we get different values reading the memory "byte after byte" via dllstructgetdata($struct,1,$i) than reading an area/region via dllstructgetdata($struct,1)?! I agree with you, probably the content of the (in the meanwhile allocated by any other program) memory changed after our $b=$a (as you mentioned above). If i "point" a new struct to that memory using a pointer with dllstructcreate(), there should be no difference reading "byte by byte" or reading a 100 bytes segment. If the memory is protected in any case, dllstructcreate()/dllstructgetdata() should throw an error. There is no error thrown, the results are different. I refuse to believe that AutoIt is "confused" by the $b=$a but if you comment that line of code, everything works. The other thing is, whats going on with those 100 bytes of memory between the line $b=$a and the following dllstructcreate(). Which program could reserve/allocate exactly this little piece of memory? $a = DllStructCreate(String("struct;byte myData[100];endstruct")) $b = DllStructCreate(String("struct;byte myData[100];endstruct")) $a_ptr = DllStructGetPtr($a) ;a ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $a_ptr = ' & $a_ptr & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $a_size = DllStructGetSize($a) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $a_size = ' & $a_size & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $b_ptr = DllStructGetPtr($b) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $b_ptr = ' & $b_ptr & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $b_size = DllStructGetSize($b) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $b_size = ' & $b_size & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console DllStructSetData($a, 1, 10, 1) ;set 10 at position 1 DllStructSetData($b, 1, 20, 1) ;set 20 at position 1 $b = $a ;so far, so good ;creating a struct at the "old" $b-struct $t = DllStructCreate("byte [100]", $b_ptr) ;look at the "previous" $b-Struct ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $t = ' & $t & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console ;reading byte by byte $ret = "0x" For $i = 1 To 100 ;show all bytes $ret &= Hex(DllStructGetData($t, 1, $i), 2) ;tadaaaa Next ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $ret = ' & $ret & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console ;reading 100 bytes $ret = DllStructGetData($t, 1) ;show all bytes doesn´t work?! ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $ret = ' & $ret & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
-
@LarsJ, yes of course you can "save" the struct respectively the pointer/names several times... But this doesn´t answers the question (of weirddave) why dllstructgetdata() returns different values when reading a single byte(s) or reading the whole (byte)-content?!
-
hmmm, exactly that´s the question....i don´t know! Possibly a cause of AutoIt´s internal access to the data...
-
Hi, no, sorry, but that doesn´t work this way! You can´t do a "memcopy" with $b=$a, the only thing you do is to "copy" the struct to it´s own position! Aka, assign the structure to an other variable: $a = DllStructCreate(String("struct;byte myData[100000000];endstruct")) $b = DllStructCreate(String("struct;byte myData[100];endstruct")) $c = DllStructCreate(String("struct;byte myData[100];endstruct")) $a_ptr = DllStructGetPtr($a) ;a ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $a_ptr = ' & $a_ptr & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $a_size = DllStructGetSize($a) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $a_size = ' & $a_size & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $b_ptr = DllStructGetPtr($b) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $b_ptr = ' & $b_ptr & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $b_size = DllStructGetSize($b) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $b_size = ' & $b_size & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $c_ptr = DllStructGetPtr($c) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $c_ptr = ' & $c_ptr & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $c_size = DllStructGetSize($c) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $c_size = ' & $c_size & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console DllStructSetData($a, 1, 10, 1) ;set 10 at position 1 DllStructSetData($b, 1, 20, 1) ;set 20 at position 1 $b = $a ;memcopy? no, NOT a memcopy! $b_ptr_after_copy = DllStructGetPtr($b) ;same ptr as $a-struct! ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $b_ptr_after_copy = ' & $b_ptr_after_copy & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $b_size_after_copy = DllStructGetSize($b) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $b_size_after_copy = ' & $b_size_after_copy & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $is_b_10 = DllStructGetData($b, 1, 1) ;show the value at position 1 ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $is_b_10 = ' & $is_b_10 & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console ;now it gets funny! the variable $b_ptr isn´t changed!!!!!!! ;is the previous structure $b deleted? or not? :o) ;if the memory at this position will be overwritten in the meantime, the script will crash here! ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $b_ptr = ' & $b_ptr & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $t = DllStructCreate("byte [100]", $b_ptr) ;look at the "previous" $b-Struct ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $t = ' & $t & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $ret = "0x" For $i = 1 To 100 ;show all bytes $ret &= Hex(DllStructGetData($t, 1, $i), 2) ;tadaaaa Next ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $ret = ' & $ret & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $ret = DllStructGetData($t, 1) ;show all bytes doesn´t work?! ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $ret = ' & $ret & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
-
passing a pointer to a child process via command line
AndyG replied to weirddave's topic in AutoIt General Help and Support
Hi, DllCall returns an array... -
passing a pointer to a child process via command line
AndyG replied to weirddave's topic in AutoIt General Help and Support
Yes. As mentioned above, you can "structure" your shared memory with structs as you need it. And place those structs into the memory where ever you like it. Let's say your shared memory size is 1.000.000 bytes and your _independant_struct1 is 8.000bytes and _independant_struct2 is 30.000bytes. You can determine/set the position of the independant structures while creating the struct(s). The "basepointer" is the pointer returned from the dll. dllstructcreate($_independant_struct1, $basepointer+$offset_what_you_like_eg_60000_bytes) creates a struct into the shared memory with a size of 8000bytes at the position "offset" 60.000 (within the shared memory) dllstructcreate($_independant_struct2, $basepointer+$offset_what_you_like_eg_110000_bytes) creates a struct into the shared memory with a size of 8000bytes at the position "offset" 110.000 (within the shared memory). All you have to do is to care about the size of the structs so that they NOT overlap (except you want this for some reason!) With dllstructcreate(struct,explicit_ptr) you NOT reserve memory, you only have access to the memory at the position "explicit_ptr"! An example how to "overlap" structures to read/get results not obviously expected ;create struct $struct =dllstructcreate("int;float[4];dword") ;fill struct with data dllstructsetdata($struct,1,123456);int dllstructsetdata($struct,2,4.80114160043301e+030,1);float dllstructsetdata($struct,2,3.68584191575527e+024,2);float dllstructsetdata($struct,2,7.71403089381636e+031,3);float dllstructsetdata($struct,2,8.24605444209785e-019,4);float dllstructsetdata($struct,3,0xDEADBEEF);dword ;read some data from struct at offset 4 $struct2=dllstructcreate("char[16]",dllstructgetptr($struct)+4) msgbox(0,":o)",dllstructgetdata($struct2,1)) -
...or make the dll-file available.
-
Hi! Very interesting article! Some time ago i noticed the (you mentioned it) time of the "conversion" of variables/strings during a DllCall of Assemblercode. The conversion of "big arrays" takes usually more time than the execution of my ASM-code....so imho the transfer of variables/strings into a ASM-code with something other than a pointer to the data is useless. This is the reason why I am not using "Arrays" in my scripts when it is necessary to process those data via ASM-code. After some profiling of the functions I have noticed that there could be a great performance boost to some of the _Array-functions, i.e. _ArraySort() Lets see what we can do
-
No, he NOT want to read a memory address, he is trying to search a string in memory....and he is looking for the "right" binary similar to the word "Active" which is 0x416374697665 in ANSI, but he needs to "transform" this into 0x410063007400690076006500 (via StringToBinary) to find this string in the memory. And furthermore, StringInStr() is much faster than this piece of **** code: For $i_search = $s_start To $s_end ConsoleWrite(Hex($i_search) & @CRLF) ;I've commented out the consolewrite because it keeps writing after exit If _MemoryRead('0x' & Hex($i_search), $f_mopen, 'char[' & StringLen($s_search) +1 & ']') = $s_search Then MsgBox (4096, $s_pname, 'String found') EndIf Next I don´t think that slower code exists...convince me! And believe me, even the included UDF´s are not needed... Why not copy the memory into a string and search FAST and EASY? He has the pointer to the memory, could create a bytestruct with the length = end-start, and can easily search with stringinstr(data_from_bytestruct,stringtobinary("Active",the_right_flag_from_my_code_in_the_post_above)).... And yes, a little bit of knowing about the VAD (process's virtual address descriptor)- tree would be helpful too!. But I think, this is far away of his skills....
-
Reinventing the wheel ? Why not use the 1000 times faster StringInStr() which can handle the search no matter of the UTF-encoding... Search the helpfile for "StringToBinary" $a = "Active" For $i = 1 To 4 $bin = StringToBinary($a, $i) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $bin = ' & $bin & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console Next
-
How to SAFELY access memory or copy memory to array?
AndyG replied to Mbee's topic in AutoIt General Help and Support
In AutoIt, you can create a dllstruct at the position of that pointer, and *voila* you have a bytearray. $bytearray_struct = DllStructCreate("byte[" & $sizeofdata & "]", $pointertodata) $data = DllStructGetData($bytearray_struct) ;bytearray -
#include <Inet.au3> $a=_INetGetSource("http://www.hearthpwn.com") ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $a = ' & $a & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console shows me the sourcecode...what i am doing wrong?
-
Automating "Industrial Software" is usually an adventure... Even if the Window-Info-Tool detect a "Handle/Control" it must not be, that this "Control" can/could be "controlled" by the AutoIt-Control-Commands. For example, i got some controls which included date/time. There was no possibility to "send" some data to those controls, the only way to automate the Software was to "click" into the control to activate the cursor, "step" to the end via sending an "end", delete the content with some "backspace"s and send the required numbers and a colon to "write" the needed time/date. Not to mention those Windows which have not the focus after they appear, and/or at the worst, not to catch with the Window-control-functions.... Usually, several routes lead to rome
-
Hi, did you read the helpfile about stringformat? Return-type of PixelChecksum() is "double" (have a look into helpfile at VarGetType()-function) , your "type-conversion" via %08x into integer can not work! The same with %12d, which is SIGNED integer also...you need an integer unsigned... $lCSum1 = PixelChecksum(0, 0, 200, 100, 1, $hWin) $lCSum1 = Int($lCSum1) ConFmtWr("CS %08x %12u %12s %d %d\n", $lCSum1, $lCSum1, $lCSum1, $bDiffN, $bDiffS) converts the double to integer, shows the Checksum in hex-view, unsigned integer and string....works now :o)