Skip to content
⌘ NSIS Forum Archive

LockedList plug-in

320 posts

Afrow UK#
New version.
2.6.1.3 - 12th July 2012
* Fixed Back button triggering auto-next during scan when /autonext is used.
http://nsis.sourceforge.net/File:LockedList.zip

Stu
Pawel#
Stu,
The newest plugin crashes for me
LockedList Unicode: 2.6.1.3
NSIS Unicode 2.46.5
Windows 7 x64 (Language PL)
Used syntax:
Function CreateLockedListPage
    ${If} ${AtLeastWinNt4}
        !insertmacro MUI_HEADER_TEXT "Title" "Subtitle"
        LockedList::AddModule "$INSTDIR\winamp.exe"
        LockedList::Dialog /heading "Text1" /colheadings "Text2" "Text3" /noprograms "Text4" /searching "Text5" /endsearch "Text6" /endmonitor "Text7" /autoclosesilent "Text8" $(^NextBtn) /menuitems "Text9" "Text10"
    ${EndIf}
    
FunctionEnd 
It crashes on the end of searching, when going to next page (Components Page).

Edit:
Last working build is: 2.6.1.0
[Build 2.6.1.1, 2.6.1.2 and 2.6.1.3 crashes]

Edit2:
ANSI build 2.6.1.3 works OK.
However, if I use /autonext option and do:
- Welcome Page -> LockedPage (not showed thanks to /autonext) -> Components Page <-- LockedPage -> I can not go to previous page, as LockedPage is autonext forward...
I hope you understand.

-Pawel
Afrow UK#
New version.
2.6.1.4 - 12th July 2012
* Fixed a crash in SystemEnum (v1.6) for the Unicode build.
http://nsis.sourceforge.net/File:LockedList.zip

Stu
SubJunk#
This is a great plugin, thanks!
Is there a way to use autonext and autoclosesilent? In other words I would like it to skip the page if the file is not locked, but if it is locked then offer an option to close it.
PoRtAbLe_StEaLtH#
Originally Posted by LoRd_MuldeR View Post
Hi.

Is sometimes get the problem that the LockedList plug-in will get stuck in the "Cancelling search, please wait..." state.



It will go on, as soon as I press some key or move the mouse cursor...

My code looks like this:


Thanks in advance for any advice 🙂


are you the developer of LameXP?
LoRd_MuldeR#
Originally Posted by PoRtAbLe_StEaLtH View Post
are you the developer of LameXP?
Yes

(You could have followed the link to my web-site in my profile)
PoRtAbLe_StEaLtH#
Originally Posted by LoRd_MuldeR View Post
Yes

(You could have followed the link to my web-site in my profile)
duh.. sorry bro..
i hardly click on profiles, links, etc ..
i come here for info, help, etc ..

i use your app all the time.. great stuff man.

@ AfrowUK
hey i have a question.. before finding your plugin.. i was using batch commands w/ handle.exe.

ie.
@echo off
for /f "tokens=3,6 delims=: " %%a in ('handle ${FILE} ^| find "pid:"') do (
set PID=%%a
set Handle=%%b
call :Stage2
)
goto end
:stage2
for /f "tokens=1 delims=:" %%a in ("%Handle%") do set Handle=%%a
REM echo %Handle% - %PID%
echo y | handle -c %Handle% -p %PID%
DEL ${FILE}
:end 

and it worked at killing the processes required to delete the file.
but it required the additional handle.exe, which installs additional registry keys, etc.

i noticed your plugin is much faster/easier to use.. ..
however.. it kills the process to everyfile in the directory.

whereas.. if i used the batch command w/ handle.exe,
only the file's process is killed.

would you know why?

Here's my coding:
IfFileExists "${FILE}" 0 NotExist_
  LockedList::AddFile "${FILE}"
  GetFunctionAddress $R0 SilentSearchCallback
  LockedList::SilentSearch $R0
  Delete "${FILE}"
  NotExist_: 
Function SilentSearchCallback
  Pop $R0
  Pop $R1
  Pop $R2
    ${If} $R0 != ""
      Push autoclose
    ${Else}
      Push false
    ${EndIf}
FunctionEnd 
Afrow UK#
It will only kill processes with a handle open on the file. If you can prove otherwise then I will need a sample script. What type of file is it by the way?

Stu
Rkuncewicz#
Hey Afrow, I recently began to use your LockedList plugin and it works beautifully! It's perfect for exactly what we need, however the only issue I am running into is that the percentage sometimes gets out of whack. At times it works fine going from 0-100%, however other times it goes up to ~55000%. It's very odd behaviour, and was just wondering if there's anything we could be doing wrong?

I'm running Windows 7 SP1, if you need anything just ask! Thanks
voidcast#
Hi,

We are using LockedList in our setups and also been getting the huge %% issue. I investigated and fixed it. Going to clean the code up a bit and suggest my fix to the community very soon.
Rkuncewicz#
Thanks! We were going to look into the issue at some point, but at the moment we are swamped with doing other things 🙂 Glad someone looked into it!
voidcast#
First of all, sorry if my memory is letting me down. I've been investigating this quite a while ago and may be wrong in details. However we made a custom LockedList build with this fix applied, put it to use in production and never seen the huge percent issue since then.

AFAIR the issue may only appear when working with LockedList::AddFile. LockedList code has a function called GetSystemHandleInformation that retrieves a structure containing all open system handles.

GetSystemHandleInformation is typically called twice: first time from GetSystemHandlesCount to get the total number of open handles and set maximum value of the progress bar, second time to iterate through handles and find processes locking the file.

Now imagine you use LockedList::AddFile and LockedList::AddModule together in your setup. For AddModule LockedList uses a totally different approach and enumerates process modules only. To set maximum value of the progress bar it calls GetSystemHandlesCount to retrieve total number of handles (say, 50000) and GetSystemModulesCount to retrieve number of modules (say, 500) and sets progress bar top to 50500. Then it starts the actual search and iterates through handles and modules.

The problem is GetSystemHandlesCount has a mistake and may fail in either of these calls. Fail in the first call will cause progress bar maximum to be 500 instead of 50500 so during the search it will go over the top and show huge percent values. Fail in the second call will break the search and file lockers will not be found.

Now about the mistake. GetSystemHandleInformation calls WinAPI function called NtQuerySystemInformation. Again it does this twice: first time to know the size of the structure to contain system handles, second time to fill the structure. The problem is number of open handles may increase between these calls so that memory allocated for SYSTEM_HANDLE_INFORMATION structure will not be enough to hold it. This is likely to happen during intense activity of other processes. In that case NtQuerySystemInformation will return STATUS_INFO_LENGTH_MISMATCH and invoker must take care of this by increasing the buffer and trying again, but LockedList does not. See http://forum.sysinternals.com/howto-...opic18892.html for reference:

An unusual aspect of calling NtQuerySystemInformation with SystemHandleInformation is that if you supply a buffer which is too small, it returns STATUS_INFO_LENGTH_MISMATCH (0xc0000004) instead of giving you the correct buffer size in ReturnLength. This means you will have to guess the buffer size. A common technique is to call NtQuerySystemInformation in a loop until it succeeds with STATUS_SUCCESS (0), reallocating and doubling the buffer size each time it fails with STATUS_INFO_LENGTH_MISMATCH.
This is what I added to GetSystemHandleInformation:

  while(size < max_size)
{
// Allocate required memory.
pSysHandleInformation = (SYSTEM_HANDLE_INFORMATION*)GlobalAlloc(GPTR, size);
if (pSysHandleInformation == NULL)
return NULL;

// Query the objects (system wide).
NTSTATUS res = NtQuerySystemInformation(SystemHandleInformation, pSysHandleInformation, size, NULL);
if (NT_SUCCESS(res))
break;
else
{
GlobalFree(pSysHandleInformation);
pSysHandleInformation = NULL;

if (res != STATUS_INFO_LENGTH_MISMATCH)
{
break;
}

size *= 2;
}
}
ntstatus.h has to be included for checking return codes. See full diff for 2.6.1.4 attached.

I suggest this to be included into project mainline.
Afrow UK#
New plug-in version:
3.0.0.0 - 1st December 2013
* Fixed GetSystemHandleInformation() failing due to change in the number of handles between NtQuerySystemInformation() calls [special thanks to voidcast].
* 64-bit module support via LockedList64.dll [special thanks to Ilya Kotelnikov].
As of v3.0.0.0, 64-bit module enumeration (for ::AddModule) is now supported. Simply extract a copy of LockedList64.dll to $PLUGINSDIR on 64-bit machines (see the LockedListKernel32.nsi example script).

Thanks for your input guys!

Stu
Rkuncewicz#
That was quite fast, thanks so much! Thanks to voidcast too, your solution worked perfectly 😁
Afrow UK#
New version:
3.0.0.1 - 7th December 2013
* Added 64-bit modules counting via LockedList64 for the progress bar and silent search.
http://nsis.sourceforge.net/LockedList_plug-in

Stu
shadowpoa#
corrupted stack

Hi Afrow,

I´m using the LockeList with silentsearch, and have noticed that at the end of function the stack is corrupted with some lockedlist internal values.

Here´s some of the example on file lockedlisttest.nsi, see the attached image to better understand what i´m saying, many thanks!

In my script I have some 'Pop´s' after the search and then I've noticed that is not the value that i'd have pushed, so I´ve used ${stack:: Debug} "0" to see the values in the stack

Section `SilentSearch asynchronous test` Section_SilentSearchThreadTest
  DetailPrint `Testing LockedList with threading, please wait...`
  LockedList::AddFile `${THE_FILE}`
  LockedList::AddModule $PLUGINSDIR\LockedList.dll
  # Begin the search in a separate thread.
  GetFunctionAddress $R0 SilentSearchCallback
  LockedList::SilentSearch $R0 /async
  # Loop while the search takes place. We could do other stuff here.
  ${Do}
    LockedList::SilentWait /time 500
    Pop $R0
  ${LoopWhile} $R0 == `/wait`
${stack::Debug} "0"
  DetailPrint `Searching... 100%`
SectionEnd 
kampel#
Hi,

the documentation of plugin and the examples has some errors:
1) The order of parameters is wrong, you have to write:
LockedList::SilentSearch /async $R0
2) The return value of fct SilentWait isn't "/wait", but only "wait"
Then the async mode works fine:-)

Thanks Stu for valuable plugin!

Kampel
Satara#
Problem with superfetch on windows

Hi,
we are using this plugin for quite a while and it does a great job. However we recently had a customer which complained that the installer was showing a program that wasn't really running. Finally it came out that it was blocked by superfetch. A windows caching mechanism to improve loading speed of executables that are used often. Would be very nice if the plugin could catch this case in the future.
Best,
Satara
Afrow UK#
What plug-in calls are you using to detect the running application? How did you come to the conclusion that superfetch is to blame? I'm not sure this is something that can be easily fixed, if at all.

Stu
Satara#
I am using
LockedList::AddCustom 
to add the executables. After we couldn't find the application in the process tab in the task manager, we noticed that the application appeared in the CPU resource monitor. We were able to perform the installation after restarting in safe mode (regular restart didn't help). But I couldn't test if it also would have worked when only stopping the superfetch service manually. I will do so if that happens again.
Afrow UK#
If you're using AddCustom then you are handling the detection yourself in a callback function... What code are you using in your callback function?

Stu
Satara#
I am sorry, I've created this quite a while ago and wasn't aware of the details anymore. In my callback I'm just using
LockedList::IsFileLocked
on the executable.