Prev Previous Post   Next Post Next
Old 26th January 2009, 08:53   #1
TobbeSweden
Senior Member
 
Join Date: Oct 2006
Posts: 106
Crash when getting user's groups

Why does the following code crash sometimes when I run it?

code:
Name "EnumUsersGroups"
OutFile "EnumUsersGroups.exe"

!macro GetUserGroups SERVER_NAME USERNAME GROUP_ARRAY_NAME
Push $R0
Push $R1
Push $R2
Push $R3

# NET_API_STATUS NetUserGetLocalGroups(
# __in LPCWSTR servername,
# __in LPCWSTR username,
# __in DWORD level,
# __in DWORD flags,
# __out LPBYTE *bufptr,
# __in DWORD prefmaxlen,
# __out LPDWORD entriesread,
# __out LPDWORD totalentries
# );

# $R0 buffer with an array of LOCALGROUP_USERS_INFO_0 structures
# $R1 holds the number of entries processed
System::Call 'netapi32::NetUserGetLocalGroups(w "${SERVER_NAME}", w "${USERNAME}", \
i 0, i 0, *i .R0, i ${NSIS_MAX_STRLEN}, *i .R1, *i .R2) i .R3'
StrCpy $R2 $R0 ; Needed to free the buffer later

# check for error
StrCmp $R3 0 +1 +2

System::Call "*$R0(w.R3)"

# Cleanup
StrCmp $R2 0 +2
System::Call 'netapi32.dll::NetApiBufferFree(i R2) i .R0'

Pop $R3
Pop $R2
Pop $R1
Pop $R0
!macroend

!define GetUserGroups "!insertmacro GetUserGroups"

ShowInstDetails show
Page instfiles

Section ""
${GetUserGroups} "" "Tobbe" GroupArray
SectionEnd


Last edited by TobbeSweden; 26th January 2009 at 09:08.
TobbeSweden is offline   Reply With Quote
 
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