In my script I am using DllCall("UpdateResource" ... to replace a resource in an executable. This is doing fine, but it is not very fast, probably because the changes are written to disk in several steps.
Is there a way to make this faster? Or--a strange question: Is it possible to update a resource in a runnig executable?
EDIT: Later tests and discussion showed that the slowness is caused by Windows Defender, since two weeks or so!!! And WD is slowing down other AHK-associated operations too. New topic: https://autohotkey.com/boards/viewtopic.php?f=5&t=49615
DllCall("UpdateResource" ... but faster?
-
- Posts: 493
- Joined: 24 Aug 2016, 03:34
DllCall("UpdateResource" ... but faster?
Last edited by newbieforever on 26 May 2018, 03:24, edited 3 times in total.
-
- Posts: 493
- Joined: 24 Aug 2016, 03:34
Re: DllCall("UpdateResource" ... but faster?
Why do you need it to be faster?
-
- Posts: 493
- Joined: 24 Aug 2016, 03:34
Re: DllCall("UpdateResource" ... but faster?
Hi, just me! Because I have to use the new exe as soon as possible.
I tested now the time consumption of the updating-process steps. The only time consuming step is DllCall("EndUpdateResource" ...
I tested now the time consumption of the updating-process steps. The only time consuming step is DllCall("EndUpdateResource" ...
Re: DllCall("UpdateResource" ... but faster?
Looking at your recent questions related to AutoHotkeySC.bin, are you trying to replace the embedded script in an Ahk.exe?
-
- Posts: 493
- Joined: 24 Aug 2016, 03:34
Re: DllCall("UpdateResource" ... but faster?
Yes, just me, I am doing this already.
Re: DllCall("UpdateResource" ... but faster?
May I ask why you think to need that?
-
- Posts: 493
- Joined: 24 Aug 2016, 03:34
Re: DllCall("UpdateResource" ... but faster?
Just me, I test ahk scripts from a CompiledScript.exe.
Re: DllCall("UpdateResource" ... but faster?
Well, but why does 'testing scripts' require to be 'faster'? How long does it take to update the script resource?
-
- Posts: 493
- Joined: 24 Aug 2016, 03:34
Re: DllCall("UpdateResource" ... but faster?
AutoHotkey.exe runs a script in a second or less, updating resource takes e.g. 15 seconds.
Re: DllCall("UpdateResource" ... but faster?
That's rather much time. I'll try to make some tests.
So long!
So long!
Re: DllCall("UpdateResource" ... but faster?
15 seconds? that is exaggerated/ridiculous. Can you show us your Script?. I've been playing changing many resources, images, icons, ... (I'm doing my own compiler) all at once, it has not taken more than a few milliseconds (on a HDD).
Re: DllCall("UpdateResource" ... but faster?
After some testing I confirm Flipeador's observations. The replacement of a ~4K AHK script needs only milliseconds here (on a SSD).
The compiler is calling UpdateResource() to add the script to the exe, too. Does it need several seconds to compile a script on your system?
The compiler is calling UpdateResource() to add the script to the exe, too. Does it need several seconds to compile a script on your system?
-
- Posts: 493
- Joined: 24 Aug 2016, 03:34
Re: DllCall("UpdateResource" ... but faster?
That's interesting!
Code: Select all
; FirstScript.exe is e.g. a simple script containing only
; RETURN
; and compiled with Unicode-32 AutoHotkeySC.bin.
; If I run the following script from AutoHotkey.exe,
; UpdateRes() takes about 3.5 s (SSD).
FirstScript := A_ScriptDir . "\FirstScript.exe"
SecondScript := A_ScriptDir . "\SecondScript.exe"
FileCopy, %FirstScript%, %SecondScript%
ScrString := "MsgBox SECOND SCRIPT"
UpdateRes(SecondScript, ScrString)
Run %SecondScript%
RETURN
UpdateRes(ExeFil, ScrStr)
{
t0 := A_TickCount
VarSetCapacity(BinScrStr, BinScrStr_Len := StrPut(ScrStr, "UTF-8") - 1)
StrPut(ScrStr, &BinScrStr, "UTF-8")
Module := DllCall("BeginUpdateResource", "str", ExeFil, "uint", 0, "ptr")
If !Module
MsgBox ERR MODULE
If !DllCall("UpdateResource", "ptr", Module, "ptr", 10, "str", ">AHK WITH ICON<"
, "ushort", 0x409, "ptr", &BinScrStr, "uint", BinScrStr_Len, "uint")
MsgBox ERR UPDATE
If !DllCall("EndUpdateResource", "ptr", Module, "uint", 0)
MsgBox ERR ENDUPDATE
t := A_TickCount - t0
MsgBox TIME: %t%
}
Last edited by newbieforever on 25 May 2018, 09:17, edited 1 time in total.
-
- Posts: 493
- Joined: 24 Aug 2016, 03:34
Re: DllCall("UpdateResource" ... but faster?
Maybe I should mention: UpdateRes() is writting a tmp file on disk during processing.
-
- Posts: 493
- Joined: 24 Aug 2016, 03:34
Re: DllCall("UpdateResource" ... but faster?
just me & Flipeador, thank you very much for your help, I see now there must be something wrong with my system. I have to find out what.
Re: DllCall("UpdateResource" ... but faster?
Maybe it's the antivirus... have you tried disabling it and running the script as Admin?...
Your Script seems fine... no idea... Does the compiler also take seconds?
Your Script seems fine... no idea... Does the compiler also take seconds?
-
- Posts: 493
- Joined: 24 Aug 2016, 03:34
Re: DllCall("UpdateResource" ... but faster?
Yes, it is a Windows Defender problem!!!
And yes, the compiler takes seconds too!
Deactivating WD enables compiling and updating of resources in ms.
WD reports a Trojan:Win32/Fuery.B!cl during compiling (indicating tmp files in Temp dir).
This is an enormous shock to me ... Will the use of AHK scripts become unreliable?
But why there are no other user reporting this problem?
I am using Windows 10 Home 10.0.16299.
And yes, the compiler takes seconds too!
Deactivating WD enables compiling and updating of resources in ms.
WD reports a Trojan:Win32/Fuery.B!cl during compiling (indicating tmp files in Temp dir).
This is an enormous shock to me ... Will the use of AHK scripts become unreliable?
But why there are no other user reporting this problem?
I am using Windows 10 Home 10.0.16299.
Re: DllCall("UpdateResource" ... but faster?
I never really noticed this. I just confirmed it using FolderChangesView. Has created an RCX4676.tmp file in the same directory as the Script.Maybe I should mention: UpdateRes() is writting a tmp file on disk during processing.
Does it detect AutoHotkey.exe?.Yes, it is a Windows Defender problem!!!
So... the compilation ends successfully or not?. Have you tried updating WD?.WD reports a Trojan:Win32/Fuery.B!cl during compiling (indicating tmp files in Temp dir).
I don't use any antivirus so I can't test it. (edit* I have MBAM Premium -i installed it not long ago- but it does not detect anything).
-
- Posts: 493
- Joined: 24 Aug 2016, 03:34
Re: DllCall("UpdateResource" ... but faster?
No other virus is detected. Compilation ends successfully. WD is updated.
EDIT: New topic: https://autohotkey.com/boards/viewtopic.php?f=5&t=49615
EDIT: New topic: https://autohotkey.com/boards/viewtopic.php?f=5&t=49615
Who is online
Users browsing this forum: marypoppins_1, mikeyww, Rohwedder, RussF and 133 guests