Old 12th July 2018, 10:47   #41
TrifonovS
Senior Member
 
Join Date: Apr 2009
Location: Bulgaria
Posts: 184
I don't call it in a section. Here is a part of my code:

PHP Code:
...

!
define MUI_PAGE_CUSTOMFUNCTION_SHOW InstFilesShow
!insertmacro MUI_PAGE_INSTFILES
...

; Function 
that is called when the installation dialog is shown
Function InstFilesShow
  
Set a function that will receive the messages to the parent window
  
${WndSubclass_Subclass$HWNDPARENT GetWinMessage $GetWinMessage $GetWinMessage
FunctionEnd
...

; Function 
that receives the messages to the parent window
Function GetWinMessage
  
${If} $= ${WM_QUERYENDSESSION}
  ...

  ${EndIf}
  ...
FunctionEnd 
TrifonovS is offline   Reply With Quote
Old 13th July 2018, 08:48   #42
TrifonovS
Senior Member
 
Join Date: Apr 2009
Location: Bulgaria
Posts: 184
I'm currently simplifying my script to be able to reproduce the problem easier. Unfortunately this is not an easy task, because the script is very complex. However I came to much simpler code that uses WndSubclass plug-in together with my special macro that makes copy of some files from the installer to some Windows folders. Now I can reproduce another crash, but I still think that the reason is the same. My macro contains on two places the following line:
PHP Code:
SetOutPath "$TEMP
First time when this line is executed, I see the correct path in the Details:
PHP Code:
Output folderC:\Users\UserName\AppData\Local\Temp 
But the second time when this line is reached the path is the following:
PHP Code:
Output folder0x0011 
It seems that the content of the system variable $TEMP is changed. I don't do this in my script (at least not intentionally ).

When I comment the line that calls the macro ${WndSubclass_Subclass} all works fine. Is this information helpful?
TrifonovS is offline   Reply With Quote
Old 13th July 2018, 10:18   #43
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,873
It is certainly possible that I messed up and have a bad pointer offset somewhere or a problem with message recursion. A complete example might still be required but I can try to take a look to see if I can reproduce it.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 13th July 2018, 10:22   #44
TrifonovS
Senior Member
 
Join Date: Apr 2009
Location: Bulgaria
Posts: 184
OK! The example is still too complex to send it to you, but I will continue with the reduction.
TrifonovS is offline   Reply With Quote
Old 14th July 2018, 15:41   #45
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,873
It might just be threading issues, NSIS was not designed to be thread safe and the sections are executed in a different thread.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 16th July 2018, 05:29   #46
TrifonovS
Senior Member
 
Join Date: Apr 2009
Location: Bulgaria
Posts: 184
Ans what could be the solution? Is it still useful to try to simplify my script for further investigation?
TrifonovS is offline   Reply With Quote
Old 16th July 2018, 15:48   #47
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,873
Quote:
Originally Posted by TrifonovS View Post
Is it still useful to try to simplify my script for further investigation?
Probably not, it's best to just give up. My guess is that GetNSISString in the stub uses a single temporary buffer and when you access strings from multiple threads at the same time things go wrong and there is not much a plug-in can do about that.

The solution is to not subclass $hwndparent nor any other window on the instfiles page.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 16th July 2018, 20:00   #48
TrifonovS
Senior Member
 
Join Date: Apr 2009
Location: Bulgaria
Posts: 184
And what about the initial idea to make a helper application that is started in parallel f the installer's executable? Do you expect the same problems?
TrifonovS is offline   Reply With Quote
Old 16th July 2018, 20:36   #49
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,873
Quote:
Originally Posted by TrifonovS View Post
And what about the initial idea to make a helper application that is started in parallel f the installer's executable? Do you expect the same problems?
Should be OK as long as you don't call any instructions that takes a variable as a parameter in any sections.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 17th July 2018, 10:58   #50
TrifonovS
Senior Member
 
Join Date: Apr 2009
Location: Bulgaria
Posts: 184
I made a helper application, but I need some more help. This helper application is programmed with the installer's script. This is the easiest way for me, since I'm not a PC programmer and programming on C++ is more difficult to me.
The problem now is that my application works fine if I show a dialog. I though that if I make it silent the dialog won't be shown, but in this case also my function that uses the plug-in is not called too (that's logical). Then I tried to call the plug-in in .onInit function, but it doesn't work. Is there a way to make this application without user interface and still to call correct the plug-in?
TrifonovS is offline   Reply With Quote
Old 17th July 2018, 11:10   #51
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,873
You have to use a hack and just hide the UI in a section. ShowWindow does not parse its parameter and should be OK IIRC.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 18th July 2018, 06:08   #52
TrifonovS
Senior Member
 
Join Date: Apr 2009
Location: Bulgaria
Posts: 184
I thought that I'm almost ready, but now another problem appeared. When I detect a message WM_QUERYENDSESSION, I write something in Windows registry (just before the reboot). But actually there is nothing written in the registry. I'm sure that the line of the script is executed, because I have some prints before and after this action. If I write the same thing before the check for this specific message, all works fine. I cannot find an explanation and solution about this...
TrifonovS is offline   Reply With Quote
Old 18th July 2018, 10:55   #53
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,873
And your code looks like this?
Quote:
Function MySubProc
${if} $2 = ${WM_QUERYENDSESSION}
writeregstr ...
${endif}
FunctionEnd

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 18th July 2018, 13:38   #54
TrifonovS
Senior Member
 
Join Date: Apr 2009
Location: Bulgaria
Posts: 184
Yes, this is exactly my code. But I thing that the code works fine, just the Regedit cannot show the change... I actually write an entry in RunOnce section to be able to call my installer after reboot. Now I saw that it works. But if I initiate Windows restart, than I cancel it, I don't see my entry (I check it with Regedit). If I reboot, it works!... I can't explain it.
TrifonovS is offline   Reply With Quote
Old 18th July 2018, 19:47   #55
Nutzzz
Junior Member
 
Join Date: May 2007
Location: Orange County, CA, U.S.A.
Posts: 49
Since NSIS is a 32-bit app, if you didn't use the command "SetRegView 64", then your entry will be automatically redirected to WOW6432Node, e.g.,
code:
HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\RunOnce

instead of e.g.,
code:
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce


As you discovered, it'll still work from that location, it's just confusing if you go looking for it with the Registry Editor.
Nutzzz is offline   Reply With Quote
Old 18th July 2018, 20:21   #56
TrifonovS
Senior Member
 
Join Date: Apr 2009
Location: Bulgaria
Posts: 184
Yes, I know this and I'm looking in the right area with Regedit:
HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\RunOnce
So this doesn't explain my observation...
TrifonovS is offline   Reply With Quote
Old 19th July 2018, 00:15   #57
Nutzzz
Junior Member
 
Join Date: May 2007
Location: Orange County, CA, U.S.A.
Posts: 49
My only other thought is you're looking in the wrong root (HKLM vs HKCU).
Nutzzz is offline   Reply With Quote
Old 19th July 2018, 05:15   #58
TrifonovS
Senior Member
 
Join Date: Apr 2009
Location: Bulgaria
Posts: 184
I checked everywhere, but there is no entry like mine. But if I call the same line of script (that writes the value in the registry), in another position in my function (for example before the check ${if} $2 = ${WM_QUERYENDSESSION}) I can see my entry exactly when I expect it in the registry. It is really strange, but I think that this is not a problem, because as I said it actually works. And I also tested it on my Windows 7 64-bit. Maybe it will be different under Windows 10...
By the way, one more question (I hope the last for this topic ). In my helper application a dialog is shown and immediately hidden (as Anders advised me). This works fine, but the dialog can be seen for a part of a second. Is there any chance to avoid this visual problem?
TrifonovS is offline   Reply With Quote
Old 19th July 2018, 05:36   #59
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,873
Start it minimized with ExecShell or move it off-screen in .onGuiInit.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 19th July 2018, 10:20   #60
TrifonovS
Senior Member
 
Join Date: Apr 2009
Location: Bulgaria
Posts: 184
So far so good. It looks that all works fine now... more tests are needed. Thanks for the good support.
TrifonovS is offline   Reply With Quote
Old 20th July 2018, 22:04   #61
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 269
Question

why when i run the loop function Check_Windows_Turned_OFF ,installer stop work and auto closed??

HTML Code:
!include "x64.nsh"
!include "WndSubclass.nsh"
!include "WinMessages.nsh"

Function Check_Windows_Turned_OFF_Action
  ${If} $2 = ${WM_QUERYENDSESSION}
	WriteRegStr HKLM "SOFTWARE\1" "1" "OFF"
    Quit
  ${EndIf} 
FunctionEnd

Function Check_Windows_Turned_OFF
FindWindow $0 "#32770" "" $HWNDPARENT
${WndSubclass_Subclass} $0 Check_Windows_Turned_OFF_Action $5 $5
FunctionEnd

Section
BK:
Call Check_Windows_Turned_OFF
Goto BK
SectionEnd
r2du-soft is offline   Reply With Quote
Old 21st July 2018, 00:28   #62
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,873
That loop makes no sense. You can't call code in sections if you are subclassing.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 21st July 2018, 10:58   #63
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 269
What is the correct way to do this?
Should change all the codes?
r2du-soft is offline   Reply With Quote
Old 23rd July 2018, 06:28   #64
TrifonovS
Senior Member
 
Join Date: Apr 2009
Location: Bulgaria
Posts: 184
I don't know if I make it right also, but if I want to avoid exit from the installer, I use the following code in the section:
PHP Code:
Dummy section
Section Dummy
ENDLESS_LOOP
:
  
Sleep 1000
  
GoTo ENDLESS_LOOP
SectionEnd 
Your function Check_Windows_Turned_OFF_Action should be called automatically on every message that is received from the dialog.
TrifonovS is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

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