View Single Post
Old 14th October 2009, 04:27   #6
demiller9
Senior Member
 
Join Date: Mar 2006
Location: Dallas
Posts: 462
Thought I found a solution, but it still crashes

I read the MSDN article on Getting WMI Data from the Local Computer and saw a note that says on Win2000 you have to specify the default authentication credentials for a user by using a SOLE_AUTHENTICATION_LIST structure in the pAuthList parameter of CoInitializeSecurity .

I've tried to do that but my program crashes now on the call to CoInitializeSecurity. I know this isn't really a NSIS problem at this point, but hope that Anders, F0rt or someone can spot what I've done wrong. Here's the part that sets up the call to CoInitializeSecurity. I have tried it with and without the SOLE_AUTHENTICATION_SERVICE structure, it crashes either way. It runs fine on XP and Vista.
code:
!define RPC_C_AUTHN_DEFAULT 0xFFFFFFFF
!define RPC_C_AUTHZ_DEFAULT 0xFFFFFFFF

${If} ${IsWin2000}
; allocate and initialize SOLE_AUTHENTICATION_INFO Structure
System::Call "*(i ${RPC_C_AUTHN_DEFAULT}, i ${RPC_C_AUTHZ_DEFAULT}, i 0)i.r2"
; allocate and initialize SOLE_AUTHENTICATION_LIST Structure
System::Call "*(i 1, i r2)i.r3"
; allocate and initialize SOLE_AUTHENTICATION_SERVICE Structure
System::Call "*(i ${RPC_C_AUTHN_DEFAULT}, i ${RPC_C_AUTHZ_DEFAULT}, i 0, i 0)i.r4"
StrCpy $5 1
${Else}
StrCpy $2 0
StrCpy $3 0
StrCpy $4 0
StrCpy $5 -1
${EndIf}

System::Call "ole32::CoInitializeSecurity( \
i 0, ; PSECURITY_DESCRIPTOR pSecDesc \
i r5, ; LONG cAuthSvc \
i r4, ; SOLE_AUTHENTICATION_SERVICE *asAuthSvc \
i 0, ; void *pReserved1 \
i ${RPC_C_AUTHN_LEVEL_DEFAULT}, ; DWORD dwAuthnLevel \
i ${RPC_C_IMP_LEVEL_IMPERSONATE}, ; DWORD dwImpLevel \
i r3, ; void *pAuthList \
i ${EOAC_NONE}, ; DWORD dwCapabilities \
i 0) i.r1"

TIA
Don
demiller9 is offline   Reply With Quote