Old 10th July 2007, 22:07   #1
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
LockedList plug-in

An NSIS plugin to display or get a list of programs that are locking a selection of files that have to be uninstalled or overwritten.

http://nsis.sf.net/File:LockedList.zip

Stu
Attached Images
File Type: png lockedlist.png (30.0 KB, 921 views)
Afrow UK is offline   Reply With Quote
Old 11th July 2007, 10:05   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
v0.2 - 11th July 2007
* Better percent complete indication.

Stu
Afrow UK is offline   Reply With Quote
Old 12th July 2007, 06:34   #3
daisywheel
Junior Member
 
Join Date: May 2007
Posts: 40
Hi Afrow UK,

Even simple script

LockedList::AddFile /NOUNLOAD $SYSDIR\kernel32.dll"
LockedList::Dialog

doesn't work for me.

I get messages "Going to compile test program and then run it"
then "The file '$TEMP\nsz1325.tmp\Lock' is now locked. It will appear on the LockedList dialog page soon..." some dialog blinks and that's all.

The same result I've got with example provided with plugin.
daisywheel is offline   Reply With Quote
Old 12th July 2007, 11:12   #4
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
Firstly, you're missing a quote and secondly that's a module not a file.

How about this script:
code:
Name "LockedList Test"
OutFile "LockedListTest.exe"

!include MUI.nsh

!insertmacro MUI_PAGE_WELCOME
Page Custom LockedListShow

!insertmacro MUI_LANGUAGE English

Function LockedListShow
LockedList::AddModule /NOUNLOAD "$SYSDIR\kernel32.dll"
LockedList::Dialog
FunctionEnd

Section
SectionEnd



You'll get some garbage for the first program captions. I might be able to fix this.

Stu
Afrow UK is offline   Reply With Quote
Old 12th July 2007, 11:30   #5
daisywheel
Junior Member
 
Join Date: May 2007
Posts: 40
Thank you for sample but it also doen't work for me.
It seems that the problem is exactly in LockedList::Dialog

I modified your sample adding three message boxes

code:

Name "LockedList Test"
OutFile "LockedListTest.exe"

!include MUI.nsh

!insertmacro MUI_PAGE_WELCOME
Page Custom LockedListShow

!insertmacro MUI_LANGUAGE English

Function LockedListShow
MessageBox MB_OK "test1"
LockedList::AddModule /NOUNLOAD "$SYSDIR\kernel32.dll"
MessageBox MB_OK "test2"
LockedList::Dialog
FunctionEnd

Section
MessageBox MB_OK "test3"
SectionEnd



and I can see only two of them.
daisywheel is offline   Reply With Quote
Old 12th July 2007, 12:32   #6
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
You're not going to see the 3rd one because the dialog stops execution of the installer until it is closed.
What exactly happens? Does the dialog not display?

Edit: Also, what OS are you on?

Stu
Afrow UK is offline   Reply With Quote
Old 12th July 2007, 12:50   #7
daisywheel
Junior Member
 
Join Date: May 2007
Posts: 40
dialog doesn't appear. installer is closed after message box "test2" closed.

OS: WinXP SP2
daisywheel is offline   Reply With Quote
Old 12th July 2007, 13:03   #8
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
That's interesting. I'm running Win XP SP2 also.

What happens if you don't use any AddFile/AddModules.

Stu
Afrow UK is offline   Reply With Quote
Old 12th July 2007, 13:59   #9
daisywheel
Junior Member
 
Join Date: May 2007
Posts: 40
ok, sorry for delay with answer. I had to deal with something.
now I'm sure that the problem is in LockedList::Dialog

I have two vesions of script
code:

Name "LockedList Test"
OutFile "LockedListTest.exe"

!include MUI.nsh

!insertmacro MUI_PAGE_WELCOME

!insertmacro MUI_PAGE_INSTFILES

Page Custom LockedListShow

!insertmacro MUI_LANGUAGE English

Function LockedListShow
MessageBox MB_OK "test1"
LockedList::AddModule /NOUNLOAD "$SYSDIR\kernel32.dll"
MessageBox MB_OK "test2"
LockedList::Dialog
FunctionEnd


Section "Install"
MessageBox MB_OK "test3"
SectionEnd



and

code:

Name "LockedList Test"
OutFile "LockedListTest.exe"

!include MUI.nsh

!insertmacro MUI_PAGE_WELCOME

Page Custom LockedListShow

!insertmacro MUI_PAGE_INSTFILES


!insertmacro MUI_LANGUAGE English

Function LockedListShow
MessageBox MB_OK "test1"
LockedList::AddModule /NOUNLOAD "$SYSDIR\kernel32.dll"
MessageBox MB_OK "test2"
LockedList::Dialog
FunctionEnd


Section "Install"
MessageBox MB_OK "test3"
SectionEnd



the first one shows message boxes
"test3"
"test1"
"test2"

the second one
"test1"
"test2"

diff:
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_INSTFILES
Page Custom LockedListShow

!insertmacro MUI_PAGE_WELCOME
Page Custom LockedListShow
!insertmacro MUI_PAGE_INSTFILES

we contact directly so I can help you debug plugin

Last edited by daisywheel; 12th July 2007 at 14:18.
daisywheel is offline   Reply With Quote
Old 12th July 2007, 14:23   #10
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
I'm aware that it is the plugin yes.

My MSN is afrowuk at tiscali dot co dot uk

Stu
Afrow UK is offline   Reply With Quote
Old 12th July 2007, 16:35   #11
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
Located the problem thanks to daisywheel
Please be patient while we make sure everything is ok then I shall upload the updated version.

Stu
Afrow UK is offline   Reply With Quote
Old 12th July 2007, 16:54   #12
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
Uploaded v0.2 RC2.
http://nsis.sf.net/File:LockedList.zip

Stu
Afrow UK is offline   Reply With Quote
Old 12th July 2007, 19:00   #13
daisywheel
Junior Member
 
Join Date: May 2007
Posts: 40
LockedList::AddModule /NOUNLOAD "$SYSDIR\module.dll"
LockedList::AddModule /NOUNLOAD "$SYSDIR\kernel32.dll"

in case file module.dll doesn't exist will result error in functionality - there will no dependencies found

in case we change order
LockedList::AddModule /NOUNLOAD "$SYSDIR\kernel32.dll"
LockedList::AddModule /NOUNLOAD "$SYSDIR\module.dll"

plugin will work in another manner. I don't think this is expected behaviour.
daisywheel is offline   Reply With Quote
Old 12th July 2007, 22:44   #14
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
Found the problem. It was a bad array pointer. It wasn't the fact of the file not being there it was simply only taking the first file or module added with AddFile/AddModule.

I was also able to fix the captions problem. I noticed captions were being repeated over multiple processes aside from the garbage caption for the first few processes. Just needed a ZeroMemory in there.

Uploaded v0.2 RC3.
http://nsis.sf.net/File:LockedList.zip

Thanks again

Stu
Afrow UK is offline   Reply With Quote
Old 13th July 2007, 07:43   #15
daisywheel
Junior Member
 
Join Date: May 2007
Posts: 40
One more suggestion. I'm not compeltely happy with results.
For example, I have two browser application run: Internet Explorer and Moxilla Firefox both on page http://nsis.sourceforge.net/File:LockedList.zip

also I use following code in a script
code:

LockedList::AddModule /NOUNLOAD "$SYSDIR\kernel32.dll"
LockedList::Dialog


and as results I've got
WINAMP.COM | Forums - LockedList plug-in - Moxilla Firefox (firefox.exe)
for Moxilla Firefox
and
AutoSuggest Drop-Down (iexplore.exe)
for IE
daisywheel is offline   Reply With Quote
Old 13th July 2007, 10:09   #16
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
Currently it grabs the first window caption for that process id by using EnumWindows. I'll look into it. Maybe I can check if the window is a child or not and if it is then skip it.

Stu
Afrow UK is offline   Reply With Quote
Old 13th July 2007, 13:11   #17
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
Realised that EnumWindows does not enumerate child windows anyway (that's what EnumChildWindows is for) so instead I'm checking to see if a window has the WS_SYSMENU style set (title bar). Now get the correct caption for Internet Explorer among others.

Uploaded v0.3:
http://nsis.sourceforge.net/File:LockedList.zip

I also documented the ::Unload function which has to be used to unload the plugin after calling SilentWait /NOUNLOAD /time #. Few other changes in the change log too.

Stu
Afrow UK is offline   Reply With Quote
Old 13th July 2007, 13:54   #18
daisywheel
Junior Member
 
Join Date: May 2007
Posts: 40
Another suggestion.

Add horizontal scroll when long name is displayed.

For now horizontal scroll is added only together with vertical one (in some cases even when it's not necessary)

Roman
daisywheel is offline   Reply With Quote
Old 13th July 2007, 14:24   #19
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
This isn't possible because the list box is actually a list view with a single hidden column set to the width of the box. The NSIS InstFiles page has the same thing. Another option would be to have a tool-tip like the InstFiles page...

Stu
Afrow UK is offline   Reply With Quote
Old 13th July 2007, 14:36   #20
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
You can use ListView_SetColumnWidth with LVSCW_AUTOSIZE, but I think the triple dot looks better. If someone wants to see the entire line, he could just hover over it instead of scrolling and then seeing just the end.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 13th July 2007, 14:40   #21
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
Yeh I agree.
How does NSIS work out how long the text being displayed is?
I'm guessing it's not just down to the number of characters...

Stu
Afrow UK is offline   Reply With Quote
Old 13th July 2007, 15:11   #22
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Size of the list view minus the size of a scroll bar. Line 1568 of Source\exehead\ui.c.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 13th July 2007, 15:17   #23
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
Yeh I've got that already... sorry meant the dots, but now I'm guessing that the list view control adds those itself anyway!!

Stu
Afrow UK is offline   Reply With Quote
Old 13th July 2007, 15:22   #24
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
The list view automatically shows the dots, but you need LVS_EX_LABELTIP for it to show the tool tip.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 13th July 2007, 15:32   #25
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
Thanks found that in Ui.c too. Very neat that it's all provided

Uploaded v0.3 RC2:
http://nsis.sourceforge.net/File:LockedList.zip

Edit: Uploaded again as it had the test executable in the Zip (+50000 bytes or so)

Stu
Afrow UK is offline   Reply With Quote
Old 5th September 2007, 08:00   #26
Wizou
Senior Member
 
Join Date: Aug 2007
Location: Paris, France
Posts: 304
Nice plugin and sources

Thanks !
Wizou is offline   Reply With Quote
Old 10th September 2007, 12:06   #27
kalverson
Senior Member
 
Join Date: May 2007
Location: Maple Grove, Minnesota
Posts: 124
During testing of various locked items, I found a minor quirk. The locking process was detected going away for the exe's, but when I exited explore (brought up inside the target install directory), that was not detected going away. I had to navigate back and then next again to repeat the locked file search to get past it to the install. Also during testing, I ran into an "out of memory" message that appeared in the dialog just before the process name. That only happened once and did not repeat itself during futher testing.
kalverson is offline   Reply With Quote
Old 14th September 2007, 10:50   #28
RobertStrong
Junior Member
 
Join Date: Jan 2006
Posts: 22
Paths

It appears that the plugin doesn't try both short and long paths so both need to be added for files / modules that may be in use with either a long or short path. Might be a nice addition for the plugin to check both behind the scenes.

Better still would be the ability to match files / modules in use by file name and then compare the paths to verify they are the same. This would also cover the unlikely scenario where the path is a combination of both long and short. Also, files / modules names can be short.

Besides that all I can say is wow... this is an extremely useful plugin.

Thanks,
Robert
RobertStrong is offline   Reply With Quote
Old 14th September 2007, 12:35   #29
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
Ah right good find. I'll see what I can do about that when I've got some time.

I plan on adding a 'file name only' lookup for the plug-in as well, and also the ability to simply show windows that have the task bar style set.

Thanks

Stu
Afrow UK is offline   Reply With Quote
Old 14th September 2007, 13:13   #30
RobertStrong
Junior Member
 
Join Date: Jan 2006
Posts: 22
SilentSearch

I just noticed that SilentSearch isn't working when the module is in use by another user. This is on Vista with fast user switching. Interestingly enough, LockedList:ialog is able to find it.

Thanks again,
Robert
RobertStrong is offline   Reply With Quote
Old 14th September 2007, 16:37   #31
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
I shall see if I can reproduce this on my XP machine soon. I do not have Vista unfortunately. This is interesting though as they are both exactly the same code bases for both functions except one directs output to the stack and one to a list view control!

Stu
Afrow UK is offline   Reply With Quote
Old 15th September 2007, 00:48   #32
RobertStrong
Junior Member
 
Join Date: Jan 2006
Posts: 22
After a quick peruse of the code it appears that EnableDebugPriv is only called when using the internal ui (e.g. LoadDialog).

*edit* that is the problem

Last edited by RobertStrong; 15th September 2007 at 01:33.
RobertStrong is offline   Reply With Quote
Old 15th September 2007, 09:25   #33
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
Oh right woops :S

Stu
Afrow UK is offline   Reply With Quote
Old 18th September 2007, 12:23   #34
kalverson
Senior Member
 
Join Date: May 2007
Location: Maple Grove, Minnesota
Posts: 124
LockedList Plug-in:

The accelerator keys do not work for the next/back buttons. Only the mouse works.
kalverson is offline   Reply With Quote
Old 18th September 2007, 12:28   #35
kalverson
Senior Member
 
Join Date: May 2007
Location: Maple Grove, Minnesota
Posts: 124
Our tester has been experiancing an intermitant crash in the LockedList.dll plug-in. The crash happens during initialization (dialog is showing 0% on progress) The image captures is too large to attach. Here is the script used:

;
; This function is called to display any locked files.
;
Function LockedListShow

;Creator function
!insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLElock)" "$(TEXT_IO_SUBTITLE2)"

LockedList::AddFile /NOUNLOAD "$INSTDIR\${PRODUCT_NAME}"
LockedList::AddModule /NOUNLOAD "$INSTDIR\${PRODUCT_NAME}\${PRODUCT_LAUNCHER_EXE}"
LockedList:ialog

FunctionEnd

Here is the crash information:

LockedList.map

0001:00001891 ?EnumSystemModules@@YGHP6GHUFILE_INFORMATION@@J@ZJ@Z 10002891 f SystemEnum.obj
0001:00001a97 ?EnumProcessIds@@YGHP6GHKJ@ZJ@Z 10002a97 f SystemEnum.obj

offset from error signature: 000029b5
base of EnumSystemModules: 2891
-------------------------------------
124 relative --> Line 478

SystemEnum.asm

; 476 :
; 477 : // Get the file path of the module.
; 478 : if (GetModuleFileNameEx(hProcess, hModules[j], File.FullPath, MAX_PATH))

push 260 ; 00000104H
mov eax, DWORD PTR [eax]
mov DWORD PTR _File$54859[ebp], eax
lea eax, DWORD PTR _File$54859[ebp+4]
push eax
mov eax, DWORD PTR -24+[ebp]
push DWORD PTR [eax]
push esi
call DWORD PTR _GetModuleFileNameEx
test eax, eax
je SHORT $L54877


SystemEnum.cod
; Line 478
00109 68 04 01 00 00 push 260 ; 00000104H
0010e 8b 00 mov eax, DWORD PTR [eax]
00110 89 85 40 fd ff
ff mov DWORD PTR _File$54859[ebp], eax
00116 8d 85 44 fd ff
ff lea eax, DWORD PTR _File$54859[ebp+4]
0011c 50 push eax
0011d 8b 45 e8 mov eax, DWORD PTR -24+[ebp]
00120 ff 30 push DWORD PTR [eax]
00122 56 push esi
00123 ff 15 00 00 00
00 call DWORD PTR _GetModuleFileNameEx
00129 85 c0 test eax, eax
0012b 74 5c je SHORT $L54877
; Line 481
kalverson is offline   Reply With Quote
Old 27th September 2007, 13:57   #36
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
New version v0.4:
http://nsis.sourceforge.net/File:LockedList.zip

Quote:
v0.4 - 27th September 2007
* Module or file names can now be just the file name as opposed to the full path.
* Folder paths are converted to full paths (some are short DOS paths) before comparison.
* Fixed typo in AddModule function (ModulesCount>FilesCount). Thanks kalverson.
* List view is now scrolled into view while items are added.
* List changed to multiple columns.
* Debug privileges were not being set under SilentSearch.
* Added /ignore switch that prevents the Next button being disabled.
* Added AddApplications to add all running applications to the list.
* Added processing mouse cursor.
* Added right-click context menu with Close and Copy List options.
* Added progress bar.
* Added default program icon for processes without an icon.
* Added code to resize controls for different dialog sizes.
I cannot reproduce that crash kalverson and by the looks of it it's out of my control, unless the module handle being passed is not valid. I could surround it by a try{} block but I am not keen on that idea.

Stu
Afrow UK is offline   Reply With Quote
Old 27th September 2007, 23:37   #37
RobertStrong
Junior Member
 
Join Date: Jan 2006
Posts: 22
Thank you Stu!
RobertStrong is offline   Reply With Quote
Old 31st March 2008, 16:33   #38
jrhutch
Junior Member
 
Join Date: Feb 2008
Location: Austin, TX
Posts: 11
I have a question about the LockedList plugin. Does AddFile support searching an entire directory? I couldn't find where it specifically said it was supported in the readme. I wanted to know that this is an option, before I go and try to fix my installer problems using this plugin.

Hopefully it does, because this plugin looks awesome and is basically the perfect solution for what I'm trying to do.
jrhutch is offline   Reply With Quote
Old 31st March 2008, 16:54   #39
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
You mean if the file is in a folder or possibly in sub folders?

Stu
Afrow UK is offline   Reply With Quote
Old 31st March 2008, 16:58   #40
jrhutch
Junior Member
 
Join Date: Feb 2008
Location: Austin, TX
Posts: 11
Yes, I want it to search my entire application directory to make sure nothing is being used before I go and try to update files. I didn't see anywhere that said wildcards were supported, but if then are, then that is fantastic. Thank you!
jrhutch is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Tags
handle, plug-in

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump