PDA

View Full Version : Call DLL sets WinLastError to 203



NewsArchive
10-28-2013, 04:41 AM
Hi Friedrich,

on two customer Machines, every call of "Call DLL" sets WinLastError to 203.

I have created a blank script with only the following lines inside:

Display Message Box "" -- "Ready"
Call DLL "kernel32.dll" -- Function "GetLastError" () ()
Set Variable %_RESULT% to "%_SB_RETURN%"
Display Message Box "Result = %_RESULT%" -- "Done"

And it returns 203, what means: ERROR_ENVVAR_NOT_FOUND - "The system
could not find the environment option that was entered."

I have written an identical Program with Delphi and it returns 0, what
is expected. So it is not Windows itself, what causes the problem.

This leads me to guess, that the Setupbuilder "call dll" script function
itself makes use of an "environment option", which does not exists on
this two machines and causes the error.

Please, could you have a look into your sources and tell me, what is
missing on this machines?

Thanks in advance.

Markus


Here is the SBEvents.txt:
|10/28/2013|11:21:17.706|Logging started: \\server05\AIDA6\Client\test.exe
|10/28/2013|11:21:17.708|Resource:
sbside.bmp->C:\Users\schnabel\AppData\Local\Temp\~SBFBD4.tmp
|10/28/2013|11:21:17.709|Resource:
sbtop.bmp->C:\Users\schnabel\AppData\Local\Temp\~SBFBD5.tmp
|10/28/2013|11:21:17.710|Resource:
0001.lib->C:\Users\schnabel\AppData\Local\Temp\~SBFBD6.tmp
|10/28/2013|11:21:17.713|RichEdID: 1
|10/28/2013|11:21:17.714|Set Variable {SELLNG} to 1033
|10/28/2013|11:21:17.719|InitScriptBegin
|10/28/2013|11:21:17.719|Set Variable {NULL} to
|10/28/2013|11:21:17.719|Set Variable {SB5VAR1} to

|10/28/2013|11:21:17.719|Set Variable {SB5VAR2} to

|10/28/2013|11:21:17.719|Set Variable {SB5VAR3} to

|10/28/2013|11:21:17.719|Set Variable %_SB_ERRORCODE% to
|10/28/2013|11:21:17.719|Set Variable %_SB_RETURN% to
|10/28/2013|11:21:17.719|Set Variable %_SB_RETURNEX% to
|10/28/2013|11:21:17.719|Set Variable %_SB_RESUME% to 0
|10/28/2013|11:21:17.719|Set Variable %_SB_TMP% to
|10/28/2013|11:21:17.719|Set Variable %_SB_PARAM1% to
|10/28/2013|11:21:17.719|Set Variable %_SB_PARAM2% to
|10/28/2013|11:21:17.719|Set Variable %_SB_PARAM3% to
|10/28/2013|11:21:17.719|Set Variable %_SB_PARAM4% to
|10/28/2013|11:21:17.719|Set Variable %_SB_PARAM5% to
|10/28/2013|11:21:17.719|Set Variable %_SB_DIALOGID% to 0
|10/28/2013|11:21:17.719|Set Variable %_SB_DIALOGNEXTID% to 0
|10/28/2013|11:21:17.719|Set Variable %_SB_DIALOGMAX% to 0
|10/28/2013|11:21:17.719|Set Variable %_SB_BUTTONID% to 0
|10/28/2013|11:21:17.719|Set Variable %_SB_CONTROLID% to 0
|10/28/2013|11:21:17.719|Set Variable %_SB_EVENTID% to 0
|10/28/2013|11:21:17.719|Set Variable %_SB_WIZHWND% to 0
|10/28/2013|11:21:17.719|Set Variable %_SB_FEATURESID% to _0000_
|10/28/2013|11:21:17.719|Set Variable %_SB_SETUPTYPEID% to 0
|10/28/2013|11:21:17.719|Set Variable %_SB_USERNAME% to install
|10/28/2013|11:21:17.719|Set Variable %_SB_USERCOMPANY% to
|10/28/2013|11:21:17.719|Set Variable %_SB_USERSERIAL% to
|10/28/2013|11:21:17.719|Set Variable %_SB_PASSWORD% to
|10/28/2013|11:21:17.719|Set Variable {WINVER} to 1024
|10/28/2013|11:21:17.719|Set Variable %WINVER% to 1024
|10/28/2013|11:21:17.719|Set Variable %SYSLNG% to 1031
|10/28/2013|11:21:17.719|Set Variable {CURLNG} to 1033
|10/28/2013|11:21:17.719|Set Variable %CURLNG% to 1033
|10/28/2013|11:21:17.719|Set Variable {WINDIR} to C:\Windows
|10/28/2013|11:21:17.719|Set Variable %WINDIR% to C:\Windows
|10/28/2013|11:21:17.719|Set Variable {SYSDIR} to %WINDIR%\System
|10/28/2013|11:21:17.719|Set Variable %SYSDIR% to %WINDIR%\System
|10/28/2013|11:21:17.719|Set Variable {SYS32DIR} to C:\Windows\SysWOW64
|10/28/2013|11:21:17.719|Set Variable %SYS32DIR% to C:\Windows\SysWOW64
|10/28/2013|11:21:17.724|Set Variable {FONTSDIR} to C:\Windows\Fonts
|10/28/2013|11:21:17.724|Set Variable %FONTSDIR% to C:\Windows\Fonts
|10/28/2013|11:21:17.724|Set Variable {TMPDIR} to
C:\Users\schnabel\AppData\Local\Temp\70575f90-3fbb-11e3-4823-00f0fbd00029
|10/28/2013|11:21:17.724|Set Variable %TMPDIR% to
C:\Users\schnabel\AppData\Local\Temp\70575f90-3fbb-11e3-4823-00f0fbd00029
|10/28/2013|11:21:17.724|Set Variable %TMPWINDIR% to
C:\Users\schnabel\AppData\Local\Temp
|10/28/2013|11:21:17.724|Set Variable %_SB_BACKUPDIR% to
C:\Users\schnabel\AppData\Local\Temp
|10/28/2013|11:21:17.724|Set Variable {PROGRAMFILESDIR} to C:\Program
Files (x86)
|10/28/2013|11:21:17.724|Set Variable %PROGRAMFILESDIR% to C:\Program
Files (x86)
|10/28/2013|11:21:17.724|Set Variable {COMMONFILESDIR} to C:\Program
Files (x86)\Common Files
|10/28/2013|11:21:17.724|Set Variable %COMMONFILESDIR% to C:\Program
Files (x86)\Common Files
|10/28/2013|11:21:17.724|Set Variable {PRIVILEGES} to Admin
|10/28/2013|11:21:17.724|Set Variable %PRIVILEGES% to Admin
|10/28/2013|11:21:17.724|Set Variable %_SB_INSTALLERFLAG% to
000110000000000000000000000000
|10/28/2013|11:21:17.724|Set Variable {CURDIR} to \\server05\AIDA6\Client
|10/28/2013|11:21:17.724|Set Variable %CURDIR% to \\server05\AIDA6\Client
|10/28/2013|11:21:17.724|Set Variable %_SB_ROOT% to
|10/28/2013|11:21:17.724|Set Variable %_SB_INSTALLDIR% to
|10/28/2013|11:21:17.724|Set Variable %_SB_ROOT% to
|10/28/2013|11:21:17.724|Set Variable {SRCDRV} to \\server05\AIDA6
|10/28/2013|11:21:17.724|Set Variable %SRCDRV% to \\server05\AIDA6
|10/28/2013|11:21:17.724|Set Variable %_SB_PROGRAMGROUP% to
|10/28/2013|11:21:17.724|Set Variable %_SB_DISKSPACEREQ% to 0
|10/28/2013|11:21:17.725|Set Variable %_SB_DISKSPACEFREE% to 0
|10/28/2013|11:21:17.725|Set Variable %_CSIDL_DESKTOP% to
C:\Users\schnabel\Desktop
|10/28/2013|11:21:17.727|Set Variable %_CSIDL_PROGRAMS% to
C:\Users\schnabel\AppData\Roaming\Microsoft\Window s\Start Menu\Programs
|10/28/2013|11:21:17.729|Set Variable %_CSIDL_PERSONAL% to
C:\Users\schnabel\Documents
|10/28/2013|11:21:17.731|Set Variable %_CSIDL_FAVORITES% to
C:\Users\schnabel\Favorites
|10/28/2013|11:21:17.732|Set Variable %_CSIDL_STARTUP% to
C:\Users\schnabel\AppData\Roaming\Microsoft\Window s\Start
Menu\Programs\Startup
|10/28/2013|11:21:17.734|Set Variable %_CSIDL_RECENT% to
C:\Users\schnabel\AppData\Roaming\Microsoft\Window s\Recent
|10/28/2013|11:21:17.735|Set Variable %_CSIDL_SENDTO% to
C:\Users\schnabel\AppData\Roaming\Microsoft\Window s\SendTo
|10/28/2013|11:21:17.737|Set Variable %_CSIDL_STARTMENU% to
C:\Users\schnabel\AppData\Roaming\Microsoft\Window s\Start Menu
|10/28/2013|11:21:17.738|Set Variable %_CSIDL_DESKTOPDIRECTORY% to
C:\Users\schnabel\Desktop
|10/28/2013|11:21:17.739|Set Variable %_CSIDL_NETHOOD% to
C:\Users\schnabel\AppData\Roaming\Microsoft\Window s\Network Shortcuts
|10/28/2013|11:21:17.739|Set Variable %_CSIDL_FONTS% to C:\Windows\Fonts
|10/28/2013|11:21:17.741|Set Variable %_CSIDL_TEMPLATES% to
C:\Users\schnabel\AppData\Roaming\Microsoft\Window s\Templates
|10/28/2013|11:21:17.742|Set Variable %_CSIDL_COMMON_STARTMENU% to
C:\ProgramData\Microsoft\Windows\Start Menu
|10/28/2013|11:21:17.744|Set Variable %_CSIDL_COMMON_PROGRAMS% to
C:\ProgramData\Microsoft\Windows\Start Menu\Programs
|10/28/2013|11:21:17.745|Set Variable %_CSIDL_COMMON_STARTUP% to
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
|10/28/2013|11:21:17.746|Set Variable %_CSIDL_COMMON_DESKTOPDIRECTORY%
to C:\Users\Public\Desktop
|10/28/2013|11:21:17.747|Set Variable %_CSIDL_APPDATA% to
C:\Users\schnabel\AppData\Roaming
|10/28/2013|11:21:17.749|Set Variable %_CSIDL_PRINTHOOD% to
C:\Users\schnabel\AppData\Roaming\Microsoft\Window s\Printer Shortcuts
|10/28/2013|11:21:17.750|Set Variable %_CSIDL_LOCAL_APPDATA% to
C:\Users\schnabel\AppData\Local
|10/28/2013|11:21:17.750|Set Variable %_CSIDL_COMMON_APPDATA% to
C:\ProgramData
|10/28/2013|11:21:17.752|Set Variable %_CSIDL_PROGRAM_FILES% to
C:\Program Files (x86)
|10/28/2013|11:21:17.752|Set Variable %_CSIDL_PROGRAM_FILES_COMMON% to
C:\Program Files (x86)\Common Files
|10/28/2013|11:21:17.754|Set Variable %_CSIDL_COMMON_DOCUMENTS% to
C:\Users\Public\Documents
|10/28/2013|11:21:17.755|Set Variable %_CSIDL_RESOURCES% to
C:\Windows\Resources
|10/28/2013|11:21:17.755|RunScriptBegin
|10/28/2013|11:21:17.755|Global: Start
|10/28/2013|11:21:17.755|Set Variable %_SB_DISKSPACEREQ% to 0
|10/28/2013|11:21:17.755|Set Variable {IDEPLOY_CLI} to IDEPLOY.CLI
|10/28/2013|11:21:17.755|sbkernel: 8.1.4210 : WinID: 1024 : HTTP_Timeout : 0
|10/28/2013|11:21:17.755|Global: End
|10/28/2013|11:21:17.755|@DISPLAYMESSAGE : Ready
|10/28/2013|11:21:19.414|Set Variable %_SB_RETURN% to 1
|10/28/2013|11:21:19.414|@CALLDLL kernel32.dll : GetLastError
|10/28/2013|11:21:19.414|Set Variable %_SB_RETURN% to 203
|10/28/2013|11:21:19.414|@SETVARIABLE (0 : 3 : 1)
|10/28/2013|11:21:19.414|Set Variable %_RESULT% to 203
|10/28/2013|11:21:19.414|@DISPLAYMESSAGE Result = 203 : Done
|10/28/2013|11:21:20.899|Set Variable %_SB_RETURN% to 1
|10/28/2013|11:21:20.899|RunScriptEnd
|10/28/2013|11:21:20.899|InitScriptBeforeScriptClose
|10/28/2013|11:21:20.899|InitScriptEnd
|10/28/2013|11:21:20.899|ShutDown1
|10/28/2013|11:21:20.899|ShutDown2
|10/28/2013|11:21:20.899|ShutDown3
|10/28/2013|11:21:20.899|RebootStatus: 0
|10/28/2013|11:21:20.899|ShutDown4
|10/28/2013|11:21:20.899|ShutDown5
|10/28/2013|11:21:20.949|ShutDown6
|10/28/2013|11:21:20.949|ShutDown7
|10/28/2013|11:21:20.949|ShutDown8
|10/28/2013|11:21:20.949|ShutDown9
|10/28/2013|11:21:20.949|FreeDialogQueueMemoryBegin
|10/28/2013|11:21:20.949|FreeDialogQueueMemoryEnd
|10/28/2013|11:21:20.950|ShutDown10
|10/28/2013|11:21:20.950|ShutDown11
|10/28/2013|11:21:20.950|Logging terminated

NewsArchive
10-28-2013, 05:58 AM
Hi Markus,

Unfortunately, I don't know why "GetLastError" returns 203 on these
machines.

I have created a small blank script project. The call to "GetLastError"
returns 0 on our test machines (XP, Windows 7 x64, Windows 8.1 x64).

The event log reports the following:

|10/28/2013|03:47:00.262|RunScriptBegin
|10/28/2013|03:47:00.262|Global: Start
|10/28/2013|03:47:00.262|Set Variable %_SB_DISKSPACEREQ% to 0
|10/28/2013|03:47:00.262|Set Variable {IDEPLOY_CLI} to IDEPLOY.CLI
|10/28/2013|03:47:00.262|sbkernel: 8.1.4210 : WinID: 16384 : HTTP_Timeout :
0
|10/28/2013|03:47:00.262|Global: End
|10/28/2013|03:47:00.262|@DISPLAYMESSAGE Ready... :
|10/28/2013|03:47:02.094|Set Variable %_SB_RETURN% to 1
|10/28/2013|03:47:02.094|@CALLDLL kernel32 : GetLastError
|10/28/2013|03:47:02.094|Set Variable %_SB_RETURN% to 0
|10/28/2013|03:47:02.094|@SETVARIABLE (0 : 1 : 1)
|10/28/2013|03:47:02.094|Set Variable %_RESULT% to 0
|10/28/2013|03:47:02.094|@SETVARIABLE (0 : 1 : 1)
|10/28/2013|03:47:02.094|Set Variable %_ERRORCODE% to 0
|10/28/2013|03:47:02.094|@DISPLAYMESSAGE Result: 0\nErrorcode: 0 :
|10/28/2013|03:47:02.917|Set Variable %_SB_RETURN% to 1
|10/28/2013|03:47:02.917|RunScriptEnd
|10/28/2013|03:47:02.917|InitScriptBeforeScriptClose
|10/28/2013|03:47:02.917|InitScriptEnd

As far as I can see (I have checked the source code), the "Call DLL..."
function does not make use of any "environment option".

Friedrich

NewsArchive
10-28-2013, 05:59 AM
Friedrich,

I believe, what your write, but as this simple script is correct and a
delphi program returns 0 where a SetupBuilder program returns 203, it is
a bug in setupbuilder and we have to fix this.

I'm sure you have further ideas (extended loggin, debug message boxes,
additional getlasterrorchecks at different points, etc.)

Thanks for your help.

Markus

NewsArchive
10-28-2013, 05:59 AM
Markus,

Unfortunately, I don't have any further idea.

The installer does not make use of environment options. Only in the "Expand
Environment Variable" script function calls the "ExpandEnvironmentStrings"
API. And the "Get Registry" functions to handle "REG_EXPAND_SZ" types.

Friedrich

NewsArchive
10-28-2013, 06:00 AM
I will see, if I can work aorund your bug. But if this isn't possible,
we (menas: you) have to investigate in this problem, because I can't
tell our customer, that he can't install our product and give him the
money (nearly 10k Eur) back.

Markus

NewsArchive
10-28-2013, 06:00 AM
Markus,

> I will see, if I can work aorund your bug. But if this isn't possible, we
> (menas: you) have to investigate in this problem, because I can't tell our
> customer, that he can't install our product and give him the money (nearly
> 10k Eur) back.

I don't think that it is a SetupBuilder "bug".

GetLastError() is supposed to return meaningful data only if the previous
Windows API call has "failed". But there might be quite a few internal
Windows API calls between the script line(s). One script function does not
mean one Windows API call.

And you can't really compare your Delphi test app with the SetupBuilder app
here. The SetupBuilder app needs more internal information (elevation
level, permissions, etc.) and all this is done automatically behind the
scenes. So perhaps one of the previous Windows API calls (in the
initialization process) returned ERROR_ENVVAR_NOT_FOUND.

If you can tell me how to reproduce the "ERROR_ENVVAR_NOT_FOUND"
GetLastError value then we can try to work around it for you.

BTW, I have seen ERROR_ENVVAR_NOT_FOUND GetLastError return values for
function calls to "SetThreadToken" and/or "SetNamedSecurityInfo". Not
directly related to environment variabls, but GetLastError returned
ERROR_ENVVAR_NOT_FOUND.

Friedrich

NewsArchive
10-28-2013, 06:05 AM
Just for fun: what happens when you "reset" the last error code.

Call DLL "kernel32" -- Function "SetLastError" (long) (0)
Call DLL "kernel32" -- Function "GetLastError" () ()

Does the 2nd "Call DLL" function still return ERROR_ENVVAR_NOT_FOUND?

Friedrich

NewsArchive
10-28-2013, 06:40 AM
Yes:

|10/28/2013|13:29:08.172|RunScriptBegin
|10/28/2013|13:29:08.172|Global: Start
|10/28/2013|13:29:08.172|Set Variable %_SB_DISKSPACEREQ% to 0
|10/28/2013|13:29:08.172|Set Variable {IDEPLOY_CLI} to IDEPLOY.CLI
|10/28/2013|13:29:08.172|sbkernel: 8.1.4210 : WinID: 1024 : HTTP_Timeout : 0
|10/28/2013|13:29:08.172|Global: End
|10/28/2013|13:29:08.172|@CALLDLL kernel32.dll : SetLastError
|10/28/2013|13:29:08.172|Set Variable %_SB_RETURN% to 0
|10/28/2013|13:29:08.172|@CALLDLL kernel32.dll : GetLastError
|10/28/2013|13:29:08.172|Set Variable %_SB_RETURN% to 203
|10/28/2013|13:29:08.172|RunScriptEnd
|10/28/2013|13:29:08.172|InitScriptBeforeScriptClose
|10/28/2013|13:29:08.172|InitScriptEnd

Project attached:
http://www.lindersoft.com/projects/Your_Project_Name_4.zip

Markus Zander

NewsArchive
10-28-2013, 06:41 AM
> I will see, if I can work aorund your bug.

We have reviewed the complete Call Dll source code. The "Call Dll"
component makes use of the following five KERNEL32.dll Windows APIs:

lstrcatA
lstrcpyA
GetProcAddress
HeapAlloc
GetProcessHeap

It does not make use of any "environment option".

Friedrich

NewsArchive
10-28-2013, 07:56 AM
Compiled your project and launched the test.exe on Windows 7. Environment
variables removed to the minimum -- Path, PSModulePath, TEMP, TMP, etc.
removed. Executed from an Admin account and a Standard User account.
GetLastError always returned 0 :-(

Friedrich

NewsArchive
10-28-2013, 07:57 AM
Marcus,

I have added the SetLastError(0) API to the runtime (just before the "Call
DLL" function is executed) to clear the last error code.

This is your test project compiled with the modified runtime:

http://www.lindersoft.com/projects/test_setlasterrorsetA.zip

Does this change anything?

Friedrich

NewsArchive
10-28-2013, 07:57 AM
BTW, this is just to find out whether the "Call DLL" function sets this
error code.

Friedrich

NewsArchive
10-28-2013, 07:58 AM
|10/28/2013|14:40:05.330|Logging started:
C:\ProgramData\AIDAOrga\Logs\test_setlasterrorsetA .exe
|10/28/2013|14:40:05.332|Resource:
0001.lib->C:\Users\HOFMEI~1\AppData\Local\Temp\~SB58F4.tmp
|10/28/2013|14:40:05.335|RichEdID: 1
|10/28/2013|14:40:05.335|Set Variable {SELLNG} to 1033
|10/28/2013|14:40:05.352|InitScriptBegin
|10/28/2013|14:40:05.352|Set Variable {NULL} to
|10/28/2013|14:40:05.353|Set Variable {SB5VAR1} to

|10/28/2013|14:40:05.353|Set Variable {SB5VAR2} to

|10/28/2013|14:40:05.353|Set Variable {SB5VAR3} to

|10/28/2013|14:40:05.353|Set Variable %_SB_ERRORCODE% to
|10/28/2013|14:40:05.353|Set Variable %_SB_RETURN% to
|10/28/2013|14:40:05.353|Set Variable %_SB_RETURNEX% to
|10/28/2013|14:40:05.353|Set Variable %_SB_RESUME% to 0
|10/28/2013|14:40:05.353|Set Variable %_SB_TMP% to
|10/28/2013|14:40:05.353|Set Variable %_SB_PARAM1% to
|10/28/2013|14:40:05.353|Set Variable %_SB_PARAM2% to
|10/28/2013|14:40:05.353|Set Variable %_SB_PARAM3% to
|10/28/2013|14:40:05.353|Set Variable %_SB_PARAM4% to
|10/28/2013|14:40:05.353|Set Variable %_SB_PARAM5% to
|10/28/2013|14:40:05.353|Set Variable %_SB_DIALOGID% to 0
|10/28/2013|14:40:05.353|Set Variable %_SB_DIALOGNEXTID% to 0
|10/28/2013|14:40:05.353|Set Variable %_SB_DIALOGMAX% to 0
|10/28/2013|14:40:05.353|Set Variable %_SB_BUTTONID% to 0
|10/28/2013|14:40:05.353|Set Variable %_SB_CONTROLID% to 0
|10/28/2013|14:40:05.353|Set Variable %_SB_EVENTID% to 0
|10/28/2013|14:40:05.353|Set Variable %_SB_WIZHWND% to 0
|10/28/2013|14:40:05.353|Set Variable %_SB_FEATURESID% to _0000_
|10/28/2013|14:40:05.353|Set Variable %_SB_SETUPTYPEID% to 0
|10/28/2013|14:40:05.353|Set Variable %_SB_USERNAME% to Microsoft
|10/28/2013|14:40:05.353|Set Variable %_SB_USERCOMPANY% to Microsoft
|10/28/2013|14:40:05.353|Set Variable %_SB_USERSERIAL% to
|10/28/2013|14:40:05.353|Set Variable %_SB_PASSWORD% to
|10/28/2013|14:40:05.353|Set Variable {WINVER} to 1024
|10/28/2013|14:40:05.353|Set Variable %WINVER% to 1024
|10/28/2013|14:40:05.353|Set Variable %SYSLNG% to 1031
|10/28/2013|14:40:05.353|Set Variable {CURLNG} to 1033
|10/28/2013|14:40:05.353|Set Variable %CURLNG% to 1033
|10/28/2013|14:40:05.353|Set Variable {WINDIR} to C:\Windows
|10/28/2013|14:40:05.353|Set Variable %WINDIR% to C:\Windows
|10/28/2013|14:40:05.353|Set Variable {SYSDIR} to %WINDIR%\System
|10/28/2013|14:40:05.353|Set Variable %SYSDIR% to %WINDIR%\System
|10/28/2013|14:40:05.353|Set Variable {SYS32DIR} to C:\Windows\SysWOW64
|10/28/2013|14:40:05.353|Set Variable %SYS32DIR% to C:\Windows\SysWOW64
|10/28/2013|14:40:05.358|Set Variable {FONTSDIR} to C:\Windows\Fonts
|10/28/2013|14:40:05.358|Set Variable %FONTSDIR% to C:\Windows\Fonts
|10/28/2013|14:40:05.358|Set Variable {TMPDIR} to
C:\Users\HOFMEI~1\AppData\Local\Temp\35c25c10-3fd7-11e3-4823-019758f00029
|10/28/2013|14:40:05.358|Set Variable %TMPDIR% to
C:\Users\HOFMEI~1\AppData\Local\Temp\35c25c10-3fd7-11e3-4823-019758f00029
|10/28/2013|14:40:05.358|Set Variable %TMPWINDIR% to
C:\Users\HOFMEI~1\AppData\Local\Temp
|10/28/2013|14:40:05.358|Set Variable %_SB_BACKUPDIR% to
C:\Users\HOFMEI~1\AppData\Local\Temp
|10/28/2013|14:40:05.358|Set Variable {PROGRAMFILESDIR} to C:\Program
Files (x86)
|10/28/2013|14:40:05.358|Set Variable %PROGRAMFILESDIR% to C:\Program
Files (x86)
|10/28/2013|14:40:05.358|Set Variable {COMMONFILESDIR} to C:\Program
Files (x86)\Common Files
|10/28/2013|14:40:05.358|Set Variable %COMMONFILESDIR% to C:\Program
Files (x86)\Common Files
|10/28/2013|14:40:05.358|Set Variable {PRIVILEGES} to Admin
|10/28/2013|14:40:05.358|Set Variable %PRIVILEGES% to Admin
|10/28/2013|14:40:05.358|Set Variable %_SB_INSTALLERFLAG% to
000110000000000001000000000000
|10/28/2013|14:40:05.358|Set Variable {CURDIR} to
C:\ProgramData\AIDAOrga\Logs
|10/28/2013|14:40:05.358|Set Variable %CURDIR% to
C:\ProgramData\AIDAOrga\Logs
|10/28/2013|14:40:05.358|Set Variable %_SB_ROOT% to
|10/28/2013|14:40:05.358|Set Variable %_SB_INSTALLDIR% to
|10/28/2013|14:40:05.358|Set Variable %_SB_ROOT% to
|10/28/2013|14:40:05.358|Set Variable {SRCDRV} to C:
|10/28/2013|14:40:05.358|Set Variable %SRCDRV% to C:
|10/28/2013|14:40:05.358|Set Variable %_SB_PROGRAMGROUP% to
|10/28/2013|14:40:05.358|Set Variable %_SB_DISKSPACEREQ% to 0
|10/28/2013|14:40:05.358|Set Variable %_SB_DISKSPACEFREE% to 0
|10/28/2013|14:40:05.360|Set Variable %_CSIDL_DESKTOP% to
C:\Users\hofmeister\Desktop
|10/28/2013|14:40:05.362|Set Variable %_CSIDL_PROGRAMS% to
C:\Users\hofmeister\AppData\Roaming\Microsoft\Wind ows\Start Menu\Programs
|10/28/2013|14:40:05.364|Set Variable %_CSIDL_PERSONAL% to
C:\Users\hofmeister\Documents
|10/28/2013|14:40:05.366|Set Variable %_CSIDL_FAVORITES% to
C:\Users\hofmeister\Favorites
|10/28/2013|14:40:05.368|Set Variable %_CSIDL_STARTUP% to
C:\Users\hofmeister\AppData\Roaming\Microsoft\Wind ows\Start
Menu\Programs\Startup
|10/28/2013|14:40:05.370|Set Variable %_CSIDL_RECENT% to
C:\Users\hofmeister\AppData\Roaming\Microsoft\Wind ows\Recent
|10/28/2013|14:40:05.371|Set Variable %_CSIDL_SENDTO% to
C:\Users\hofmeister\AppData\Roaming\Microsoft\Wind ows\SendTo
|10/28/2013|14:40:05.373|Set Variable %_CSIDL_STARTMENU% to
C:\Users\hofmeister\AppData\Roaming\Microsoft\Wind ows\Start Menu
|10/28/2013|14:40:05.374|Set Variable %_CSIDL_DESKTOPDIRECTORY% to
C:\Users\hofmeister\Desktop
|10/28/2013|14:40:05.376|Set Variable %_CSIDL_NETHOOD% to
C:\Users\hofmeister\AppData\Roaming\Microsoft\Wind ows\Network Shortcuts
|10/28/2013|14:40:05.376|Set Variable %_CSIDL_FONTS% to C:\Windows\Fonts
|10/28/2013|14:40:05.378|Set Variable %_CSIDL_TEMPLATES% to
C:\Users\hofmeister\AppData\Roaming\Microsoft\Wind ows\Templates
|10/28/2013|14:40:05.379|Set Variable %_CSIDL_COMMON_STARTMENU% to
C:\ProgramData\Microsoft\Windows\Start Menu
|10/28/2013|14:40:05.381|Set Variable %_CSIDL_COMMON_PROGRAMS% to
C:\ProgramData\Microsoft\Windows\Start Menu\Programs
|10/28/2013|14:40:05.382|Set Variable %_CSIDL_COMMON_STARTUP% to
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
|10/28/2013|14:40:05.384|Set Variable %_CSIDL_COMMON_DESKTOPDIRECTORY%
to C:\Users\Public\Desktop
|10/28/2013|14:40:05.385|Set Variable %_CSIDL_APPDATA% to
C:\Users\hofmeister\AppData\Roaming
|10/28/2013|14:40:05.386|Set Variable %_CSIDL_PRINTHOOD% to
C:\Users\hofmeister\AppData\Roaming\Microsoft\Wind ows\Printer Shortcuts
|10/28/2013|14:40:05.387|Set Variable %_CSIDL_LOCAL_APPDATA% to
C:\Users\hofmeister\AppData\Local
|10/28/2013|14:40:05.388|Set Variable %_CSIDL_COMMON_APPDATA% to
C:\ProgramData
|10/28/2013|14:40:05.389|Set Variable %_CSIDL_PROGRAM_FILES% to
C:\Program Files (x86)
|10/28/2013|14:40:05.390|Set Variable %_CSIDL_PROGRAM_FILES_COMMON% to
C:\Program Files (x86)\Common Files
|10/28/2013|14:40:05.391|Set Variable %_CSIDL_COMMON_DOCUMENTS% to
C:\Users\Public\Documents
|10/28/2013|14:40:05.393|Set Variable %_CSIDL_RESOURCES% to
C:\Windows\Resources
|10/28/2013|14:40:05.393|RunScriptBegin
|10/28/2013|14:40:05.393|Global: Start
|10/28/2013|14:40:05.393|Set Variable %_SB_DISKSPACEREQ% to 0
|10/28/2013|14:40:05.393|Set Variable {IDEPLOY_CLI} to IDEPLOY.CLI
|10/28/2013|14:40:05.393|sbkernel: 8.1.4210 : WinID: 1024 : HTTP_Timeout : 0
|10/28/2013|14:40:05.393|Global: End
|10/28/2013|14:40:05.393|SetLastError(0)
|10/28/2013|14:40:05.393|@CALLDLL kernel32.dll : SetLastError
|10/28/2013|14:40:05.393|Set Variable %_SB_RETURN% to 0
|10/28/2013|14:40:05.393|SetLastError(0)
|10/28/2013|14:40:05.393|@CALLDLL kernel32.dll : GetLastError
|10/28/2013|14:40:05.393|Set Variable %_SB_RETURN% to 203
|10/28/2013|14:40:05.393|RunScriptEnd
|10/28/2013|14:40:05.393|InitScriptBeforeScriptClose
|10/28/2013|14:40:05.393|InitScriptEnd
|10/28/2013|14:40:05.393|ShutDown1
|10/28/2013|14:40:05.393|ShutDown2
|10/28/2013|14:40:05.393|ShutDown3
|10/28/2013|14:40:05.393|RebootStatus: 0
|10/28/2013|14:40:05.393|ShutDown4
|10/28/2013|14:40:05.393|ShutDown5
|10/28/2013|14:40:05.443|ShutDown6
|10/28/2013|14:40:05.443|ShutDown7
|10/28/2013|14:40:05.443|ShutDown8
|10/28/2013|14:40:05.444|ShutDown9
|10/28/2013|14:40:05.444|FreeDialogQueueMemoryBegin
|10/28/2013|14:40:05.444|FreeDialogQueueMemoryEnd
|10/28/2013|14:40:05.444|ShutDown10
|10/28/2013|14:40:05.444|ShutDown11
|10/28/2013|14:40:05.444|Logging terminated

Markus Zander

NewsArchive
10-28-2013, 07:59 AM
FWIW, I get a %_SB_RETURN% of 2 if I comment out the SetLastError and
zero with the SetLastError() in place.

This is on Markus' script.

The SetLastError() seems like a reasonable way de-undefine the last
error.

SB7 had the exact same behavior.

Jeff Slarve
www.jssoftware.com
www.twitter.com/jslarve
I'll search help files & Google for you.

NewsArchive
10-28-2013, 09:39 AM
> |10/28/2013|14:40:05.393|SetLastError(0)
> |10/28/2013|14:40:05.393|@CALLDLL kernel32.dll : SetLastError
> |10/28/2013|14:40:05.393|Set Variable %_SB_RETURN% to 0
> |10/28/2013|14:40:05.393|SetLastError(0)
> |10/28/2013|14:40:05.393|@CALLDLL kernel32.dll : GetLastError
> |10/28/2013|14:40:05.393|Set Variable %_SB_RETURN% to 203

Okay, that means the "GetLastError" value is definitely set in the "Call
DLL" function.

I have removed all environment variables in Windows 7 (expect the following
ones) and still do not see ERROR_ENVVAR_NOT_FOUND:

NUMBER_OF_PROCESSORS
OS
PROCESSOR_ARCHITECTURE
PROCESSOR_IDENTIFIER
PROCESSOR_LEVEL
PROCESSOR_REVISION
windir

I'll add some more event messages to find out which API sets the error code.

Friedrich

NewsArchive
10-28-2013, 09:40 AM
I have added more event log "breakpoints".

This is your test project compiled with the modified runtime:

http://www.lindersoft.com/projects/test_setlasterrorsetB.zip

c:\test\test_setlasterrorsetB.exe /E2 "c:\test\test.txt"

Could you please post the resulting event log?

Thanks,
Friedrich

NewsArchive
10-28-2013, 09:40 AM
|10/28/2013|16:05:10.879|RunScriptBegin
|10/28/2013|16:05:10.879|Global: Start
|10/28/2013|16:05:10.879|Set Variable %_SB_DISKSPACEREQ% to 0
|10/28/2013|16:05:10.879|Set Variable {IDEPLOY_CLI} to IDEPLOY.CLI
|10/28/2013|16:05:10.879|sbkernel: 8.1.4210 : WinID: 1024 : HTTP_Timeout : 0
|10/28/2013|16:05:10.879|Global: End
|10/28/2013|16:05:10.880|@CALLDLL kernel32.dll : SetLastError
|10/28/2013|16:05:10.880|@GETLASTERROR_1 2
|10/28/2013|16:05:10.880|@GETLASTERROR_2 2
|10/28/2013|16:05:10.880|@GETLASTERROR_7 2
|10/28/2013|16:05:10.880|@GETLASTERROR_8 203
|10/28/2013|16:05:10.880|@GETLASTERROR_9 203
|10/28/2013|16:05:10.880|@GETLASTERROR_10 203
|10/28/2013|16:05:10.880|@GETLASTERROR_11 203
|10/28/2013|16:05:10.880|@GETLASTERROR_12 203
|10/28/2013|16:05:10.880|@GETLASTERROR_13 203
|10/28/2013|16:05:10.880|@GETLASTERROR_14 203
|10/28/2013|16:05:10.880|@GETLASTERROR_15 203
|10/28/2013|16:05:10.880|@GETLASTERROR_16 203
|10/28/2013|16:05:10.880|@GETLASTERROR_17 0
|10/28/2013|16:05:10.880|@GETLASTERROR_19 0
|10/28/2013|16:05:10.880|@GETLASTERROR_20 0
|10/28/2013|16:05:10.880|@GETLASTERROR_21 0
|10/28/2013|16:05:10.880|@GETLASTERROR_22 0
|10/28/2013|16:05:10.880|@GETLASTERROR_23 0
|10/28/2013|16:05:10.880|@GETLASTERROR_24 0
|10/28/2013|16:05:10.880|Set Variable %_SB_RETURN% to 0
|10/28/2013|16:05:10.880|SetLastError(0)
|10/28/2013|16:05:10.880|@CALLDLL kernel32.dll : GetLastError
|10/28/2013|16:05:10.880|@GETLASTERROR_1 0
|10/28/2013|16:05:10.880|@GETLASTERROR_2 0
|10/28/2013|16:05:10.880|@GETLASTERROR_7 0
|10/28/2013|16:05:10.880|@GETLASTERROR_8 203
|10/28/2013|16:05:10.880|@GETLASTERROR_9 203
|10/28/2013|16:05:10.880|@GETLASTERROR_10 203
|10/28/2013|16:05:10.880|@GETLASTERROR_11 203
|10/28/2013|16:05:10.880|@GETLASTERROR_12 203
|10/28/2013|16:05:10.880|@GETLASTERROR_13 203
|10/28/2013|16:05:10.880|@GETLASTERROR_16 203
|10/28/2013|16:05:10.880|@GETLASTERROR_17 203
|10/28/2013|16:05:10.880|@GETLASTERROR_19 203
|10/28/2013|16:05:10.880|@GETLASTERROR_20 203
|10/28/2013|16:05:10.880|@GETLASTERROR_21 203
|10/28/2013|16:05:10.880|@GETLASTERROR_22 203
|10/28/2013|16:05:10.880|@GETLASTERROR_23 203
|10/28/2013|16:05:10.880|@GETLASTERROR_24 203
|10/28/2013|16:05:10.880|Set Variable %_SB_RETURN% to 203
|10/28/2013|16:05:10.880|SetLastError(0)
|10/28/2013|16:05:10.880|RunScriptEnd

Am 28.10.2013 16:01, schrieb Friedrich Linder:
> /E2 "c:\test\test.txt"

Markus Zander

NewsArchive
10-28-2013, 09:41 AM
> |10/28/2013|16:05:10.879|RunScriptBegin
> |10/28/2013|16:05:10.879|Global: Start
> |10/28/2013|16:05:10.879|Set Variable %_SB_DISKSPACEREQ% to 0
> |10/28/2013|16:05:10.879|Set Variable {IDEPLOY_CLI} to IDEPLOY.CLI
> |10/28/2013|16:05:10.879|sbkernel: 8.1.4210 : WinID: 1024 : HTTP_Timeout :
> 0
> |10/28/2013|16:05:10.879|Global: End
> |10/28/2013|16:05:10.880|@CALLDLL kernel32.dll : SetLastError
> |10/28/2013|16:05:10.880|@GETLASTERROR_1 2
> |10/28/2013|16:05:10.880|@GETLASTERROR_2 2
> |10/28/2013|16:05:10.880|@GETLASTERROR_7 2
> |10/28/2013|16:05:10.880|@GETLASTERROR_8 203
> |10/28/2013|16:05:10.880|@GETLASTERROR_9 203

Okay, it happens between "breakpoint" 7 and 8:

This is the original "C" source code:

---

wsprintf(TmpString1, "@GETLASTERROR_7 %i", GetLastError());
LogAction(TmpString1, ScriptLogHandle, g_DebugMode);

hInst = LoadLibrary(Para1);

wsprintf(TmpString1, "@GETLASTERROR_8 %i", GetLastError());
LogAction(TmpString1, ScriptLogHandle, g_DebugMode);

---

That means, the LoadLibrary Windows API sets the last-error value to
ERROR_ENVVAR_NOT_FOUND on this machine.

Friedrich

NewsArchive
10-28-2013, 09:41 AM
In other words, LoadLibrary("kernel32.dll"); sets the last-error value to
ERROR_ENVVAR_NOT_FOUND on this machine.

Friedrich

NewsArchive
10-28-2013, 09:42 AM
Also, I ran that same test.exe on 3 different machines. Without the
SetLastError(), all return 2.

Jeff Slarve
www.jssoftware.com
www.twitter.com/jslarve
I'll search help files & Google for you.

NewsArchive
10-28-2013, 09:42 AM
Hi Jeff,

> Also, I ran that same test.exe on 3 different machines. Without the
> SetLastError(), all return 2.

Thanks for testing.

Yes, that's correct. It returns "2" in this case. And if you add a simple
"Display Message Box" before the "Call DLL" function then it returns "0".

For example:

Display Message Box "Ready..." -- ""

We do not set the error-value from the runtime, Windows handles this
automatically. GetLastError() always returns the last-error code value. If
last-error value is ERROR_ENVVAR_NOT_FOUND then Windows set it to this value
(for whatever reason) in one of the previous Windows API calls.

Thanks again.

Friedrich

NewsArchive
10-28-2013, 09:43 AM
I had noticed the messagebox thing as well, because I was going to
offer a choice of whether to call SetLastError(). However, it seemed I
was always answering yes<g>

Jeff Slarve
www.jssoftware.com
www.twitter.com/jslarve
I'll search help files & Google for you.

NewsArchive
10-28-2013, 09:43 AM
> I had noticed the messagebox thing as well, because I was going to
> offer a choice of whether to call SetLastError(). However, it seemed I
> was always answering yes<g>

<G> :-)

Friedrich

NewsArchive
10-28-2013, 10:48 AM
Thank you. This information leads me to the following workaround:

Set Variable %KERNEL32HANDLE% to FUNCTION:Load DLL("kernel32.dll")
Call DLL "%KERNEL32HANDLE%" -- Function "SetLastError" (long) (0)
Call DLL "%KERNEL32HANDLE%" -- Function "GetLastError" () ()

Markus Zander

NewsArchive
10-28-2013, 10:49 AM
> Thank you. This information leads me to the following workaround:
>
> Set Variable %KERNEL32HANDLE% to FUNCTION:Load DLL("kernel32.dll")
> Call DLL "%KERNEL32HANDLE%" -- Function "SetLastError" (long) (0)
> Call DLL "%KERNEL32HANDLE%" -- Function "GetLastError" () ()

The main question is, why does LoadLibrary() succeed on this machine but
sets the last-error value to ERROR_ENVVAR_NOT_FOUND. If I were you, I would
try to pass a fully qualified DLL name (instead of kernel32.dll) to see if
that helps. This seems to be a machine specific problem (perhaps there is
something wrong with the DLL search strategy on this machine).

Just for the records: this is NOT caused by a SetupBuilder bug! Because the
LoadLibrary Windows API really sets the last-error value to
ERROR_ENVVAR_NOT_FOUND, the GetLastError "Call Dll..." script function
returns the correct error code here.

Friedrich

NewsArchive
10-28-2013, 10:49 AM
> try to pass a fully qualified DLL name (instead of kernel32.dll) to see if

Already tried this morning - without success.

Markus Zander

NewsArchive
10-28-2013, 12:55 PM
>> try to pass a fully qualified DLL name (instead of kernel32.dll) to see
>> if
>
> Already tried this morning - without success.
>

Aha, okay. I have Goggled and there are a few threads related to this
issue. But there is no solution mentioned.

BTW, here is an interesting source code snipped. I think what happens on
this machine is that Windows tries to retrieve (as part of the LoadLibrary
call) the name of the system folder and this process fails (for unknown
reasons) with error ERROR_ENVVAR_NOT_FOUND. LoadLibrary itself succeeds,
but the last-error value is not "cleared".

Friedrich

NewsArchive
10-28-2013, 12:55 PM
Could it be a constructor in the DLL?

Jeff Slarve
www.jssoftware.com
www.twitter.com/jslarve
I'll search help files & Google for you.

NewsArchive
10-28-2013, 12:56 PM
Hi Jeff,

>
> Could it be a constructor in the DLL?
>

To be honest, I have no idea. The funny thing is, the LoadLibrary Windows
API sets this last-error value ERROR_ENVVAR_NOT_FOUND when it loads the
kernel32 (the Windows Kernel). The LoadLibrary call succeeds, but the
last-error value is set. Does not make any sense and is against "the rules"
<g>. If LoadLibrary succeeds, the last error code "should" not be touched.

Friedrich

NewsArchive
10-29-2013, 05:51 AM
> FWIW, I get a %_SB_RETURN% of 2 if I comment out the SetLastError and
> zero with the SetLastError() in place.

I have changed this behavior in the latest internal build. The runtime
initialization "clears" the error buffer now.

---
CHANGE : After the internal runtime initialization process, the
last-error value is reset to 0.
---

Friedrich