Skip to content
⌘ NSIS Forum Archive

NDIS Driver installation

57 posts

jweinraub#
Where does
RequestExecutionLevel admin
go? In the beginning: !define RequestExecutionLevel admin?
jweinraub#
I don't know if its related but other than fixing a few logical errors (by removing the old winver stuff), the code compiles but crashes (no error, visual studio JIT caught it and the disassembly makes no sense).
7C810847 mov eax,dword ptr [esi]
unless that request execution caused it?
Anders#
Originally Posted by jweinraub View Post
I don't know if its related but other than fixing a few logical errors (by removing the old winver stuff), the code compiles but crashes (no error, visual studio JIT caught it and the disassembly makes no sense).

unless that request execution caused it?
We are going to need some more details.

Does it crash at startup? Before .onInit? In System::Call?

Does example1.nsi crash?
jweinraub#
Soon as I run setup.exe and perms get elevated in 7, or soon as it runs on XP. Therefore, I assume, it is onInit since the welcome screen doesn't occur yet.
JasonFriday13#
So put in a MessageBox on the first line in .onInit and see if it shows. If it does show then there is a problem with the script somewhere.
jweinraub#
example works fine, i have so much stuff in onInit it will be too hard to remove the logic to take it out, however, only thing i changed was removing the getversions to the newer style from winver.nsh to be compatible with 8.1 stuff. i even compiled using the 3b1 nsis compiler. i really can't think what else recently changed.
jweinraub#
Originally Posted by JasonFriday13 View Post
So put in a MessageBox on the first line in .onInit and see if it shows. If it does show then there is a problem with the script somewhere.
Yes. welcome msgbox showed, then crash. good idea, now i will iterate through it until i find the cause. i am guessing it is a plugin.
jweinraub#
It seems definitely to do with the winver.nsh stuff.
the other problem i had was a logical error which i should had spotted, but the crashing is definitely winver...


${IfNot} ${AtLeastWinXP}
MessageBox MB_OK|MB_ICONSTOP "Your installed version of Windows is not supported by the Foobar software." IDOK
Quit
${EndIf}

MessageBox MB_OK "We are now past AtLeastXP" IDOK

${If} ${IsWin8}
${OrIf} ${IsWin8.1}
MessageBox MB_YESNO|MB_ICONEXCLAMATION|MB_TOPMOST|MB_DEFBUTTON2 \
"This Foobar software is being tested on, but is not fully supported on Windows 8.$\r$\n$\r$\nFoobar Enterprises cannot \
provide technical support for this installation.$\r$\n$\r$\nDo you still want to continue with the installation?" \
IDYES further IDNO done
${EndIf}
MessageBox MB_OK "We are now passed Win8 checks" IDOK
its removal allows the installer to work.
Anders#
Name "Test (${NSIS_PACKEDVERSION}:${NSIS_CHAR_SIZE}:${NSIS_PTR_SIZE})"
Outfile "$%Temp%\Test.exe"
RequestExecutionLevel user

!include WinVer.nsh

Function .onInit
${IfNot} ${AtLeastWinXP}
MessageBox MB_OK|MB_ICONSTOP "Your installed version of Windows is not supported by the Foobar software." IDOK
Quit
${EndIf}

MessageBox MB_OK "We are now past AtLeastXP" IDOK

${If} ${IsWin8}
${OrIf} ${IsWin8.1}
MessageBox MB_YESNO|MB_ICONEXCLAMATION|MB_TOPMOST|MB_DEFBUTTON2 \
"This Foobar software is being tested on, but is not fully supported on Windows 8.$\r$\n$\r$\nFoobar Enterprises cannot \
provide technical support for this installation.$\r$\n$\r$\nDo you still want to continue with the installation?" \
IDYES further IDNO done
${EndIf}
further:
done:
MessageBox MB_OK "We are now passed Win8 checks" IDOK
FunctionEnd

Section
SectionEnd
Works fine on XP.SP3, Win8.RTM and Win10.TP
jweinraub#
Is my Winver.nsh bad? Why would its removal cause it work now? I assume my code logic is right to prohibit anything below XP, warning for the 8s and anything else (Vista, 7, 8+) to work? Including server versions?
Anders#
Have you tried uninstalling NSIS and re-installing it? I don't believe WinVer.nsh has changed in the last few releases but I guess you upgraded from 2.46?

If it still crashes you can compile my exact example code and upload the .exe somewhere and I might be able to take a look...

Originally Posted by jweinraub View Post
I assume my code logic is right to prohibit anything below XP, warning for the 8s and anything else (Vista, 7, 8+) to work? Including server versions?
Win10 is detected as Win8.1 because of the way compatibility hacks are applied to GetVersionEx by Windows. ${IsServerOS} is used to detect server versions. 2012 and 2012R2 will be detected as "Win8" in your code because the version number is the same as the client versions...

If you want to avoid detecting Win10 as Win8.1 you must add this:
ManifestSupportedOS Win7 Win8 Win8.1 {8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}
jweinraub#
okay i got it to work. the developer said the path thing was regarding older legacy stuff that never got removed until now. i removed the addtopath, and replaced the makensis with the stock one over the special built one mean for long strings since that is no longer a concern, it now works fine. not too sure why the special makensis was incompatible with the winver.nsh, but now it works, the driver installed fine, no popups, now i jjust need to clean up some other logical corrections in other areas from the migration of the newer way to of detecting which architecture is installed so it can install the correct version of .net if it is needed, but other than that, i appreciate all the help anders and patience with bearing with me.

but to be clear on the execution, is this right, in the correct area, or is it not needed?

!define PRODUCT_UNINST_ROOT_KEY "HKLM"
!define SHCNE_ASSOCCHANGED 0x08000000
!define SHCNF_IDLIST 0
!define ALL_USERS
!define RequestExecutionLevel admin
Anders#
RequestExecutionLevel is not a define. I usually place it near the top but it does not really matter.

The large strings build for 3.0b1 worked fine for me on XP.SP3 with the code I posted.
jweinraub#
Weird. At any rate, if path isn't needed, I won't need the special build anyway.

Not sure why it crashed there, but at least that is fixed, but the original issue on installing the driver i needed is fixed, but uninstalling doesn't do anything.
# Remove the filter....
nsExec::Exec '"$windir\sysnative\netcfg.exe" -u foobar' $R1
Anders#
Originally Posted by jweinraub View Post
but uninstalling doesn't do anything.
Verify that the process is started with the command line you expect by using Process Explorer or Process Monitor, beyond that I don't think we can be of much help and you probably have to return to the OSR mailing list...
jweinraub#
Bizarre. Maybe it gets removed not immediately, ran procmon and it was fine and now it seems the driver was uninstalled fine.

since i am still new to the winver can you help me figure this one last thing out the if/and if logic is very wrong but not sure how to compound this to negate not running x64 since that is my last problem

; Detect .net 2.0 here ;
System::Call `mscoree::GetCORVersion(w .R0, i ${NSIS_MAX_STRLEN}, *i) ?u`
StrCpy $R0 $R0 1 1

; Compare if $R0 < 2 using ${If}
${If} $R0 < 2
; First detect if this is a 64 bit OS because you will want to install that instead ...
${AndIf} ${RunningX64} ; it seems this happens regardless if 2.0 is installed already or not. b/c of the and.
SetDetailsPrint textonly
DetailPrint "Installing Microsoft .NET 2.0 x64. This may take up to ten minutes, please be patient."
SetDetailsPrint none
ExecWait `"$INSTDIR\Misc\NetFx64.exe" /q:a /c:"install.exe /noaspupgrade /qb"` $R0
${Else} ; so does this
SetDetailsPrint textonly
DetailPrint "Installing Microsoft .NET 2.0..."
SetDetailsPrint none
ExecWait `"$INSTDIR\Misc\dotnetfx.exe" /q:a /c:"install.exe /noaspupgrade /qb"` $R0
${EndIf}
; this doesnt happen on XP now for some reason.
FooPlug::Show
${If} $1 == "YES"
Goto install_foo
${Else}
Goto skip_it
${EndIf}
Anders#
That logic does not make sense to me, on non-x64 platforms it will always install.

Why not use:

System::Call `mscoree::GetCORVersion(w .R0, i ${NSIS_MAX_STRLEN}, *i) ?u`
StrCpy $R0 $R0 1 1
${If} $R0 < 2
; .net 2 not installed, install it now:
${If} ${RunningX64}
ExecWait `"$INSTDIR\Misc\NetFx64.exe" /q:a /c:"install.exe /noaspupgrade /qb"` $R0
${Else}
ExecWait `"$INSTDIR\Misc\dotnetfx.exe" /q:a /c:"install.exe /noaspupgrade /qb"` $R0
${EndIf}
${EndIf}
jweinraub#
OMG. I feel so stupid. Didn't think I can nest the if's like that lol.
Ok thank you anders. time for more much needed coffee and rest.
JasonFriday13#
Glad you got it figured out.

Do you still need to modify the Path environment variable? I've spent the last week or so writing, testing and bugfixing a plugin to work with environment variables, it just needs intensive testing to find rare bugs I haven't caught yet.
jweinraub#
Not sure. The developers told me to take it out now to test it to see if it is still needed. I am trying to figure out one of the custom dlls I did make, no longer works in WinXP.

Got
The procedure entry point InitOnceExecuteOnce could not be located in the dynamic link library KERNEL32.dll.

Error loading foobar.dll

The specified procedure could not be found.

When I ran rundll32 foobar.dll Show

It works fine in Win7.
I had to rework some of it to get it to compile in VS2012 from the original 2010 project but everything else should be fine, I would thought, it is Win32 API, no mfc or .net dependency to worry about.
JasonFriday13#
Dependency Walker for mine is showing Shlwapi.dll, Kernel32.dll, User32.dll, and Advapi32.dll. It should work on XP and up. Also it should be x64 ready but I haven't got to compiling it for x64 yet.
Anders#
InitOnceExecuteOnce was added in Vista IIRC. Use a critical section or InterlockedCompareExchange if you need to support older platforms...
jweinraub#
Originally Posted by Anders View Post
InitOnceExecuteOnce was added in Vista IIRC. Use a critical section or InterlockedCompareExchange if you need to support older platforms...
Where would that go exactly?


void setvar( int varnum, char * var )
{
if (var != NULL && varnum >= 0 && varnum < __INST_LAST)
{
lstrcpy (g_variables + varnum*g_stringsize, var);
}
}

// Gets user variable
char *getvar(int varnum)
{
if (varnum < 0 || varnum >= __INST_LAST)
return NULL;
return g_variables + varnum*g_stringsize;
}

void __declspec(dllexport) Show(HWND hwndParent, int string_size, char *variables, stack_t **stacktop)
{
g_hwndParent=hwndParent;
g_stringsize=string_size;
g_variables=variables;
res = runDialogBox();
if ( res == 0 )
setvar(INST_1,"NO" );
else
setvar(INST_1,"YES" );
}

int runDialogBox()
{
int result = FALSE;
result = DialogBoxParam(hModule, MAKEINTRESOURCE(IDD_DIALOG), NULL, dlgBox, NULL);

return result;
}
Anders#
I don't see InitOnceExecuteOnce in your code. If you don't have it in your code then it must come from the CRT. Change the target/toolchain in VS to a version that supports XP or use a older version of VS.
JasonFriday13#
Is that it? Where's your DllMain? My plugin is roughly 540 lines long. But I'm checking variable types and doing intelligent string processing so I can add and remove values/paths inside a variable with multiple values/paths.
jweinraub#
no, that was a very abridged version of my plugin, it isn't anything to do with the path, my plugin was for a security component of the software, changing the toolchain as anders suggested worked, had to download sp4 for visual studio, and change the target to xp_2012