vc++ install requires NetUserModalsGet

Saulius Krasuckas saulius2 at ar.fi.lt
Fri Aug 6 04:41:04 CDT 2004


On Sat, 31 Jul 2004, James Hawkins wrote:
> Looking into netapi32/access.c, NetUserModalsGet is a stub and returns
> NERR_InternalError by default.  I think vcsetup is requiring this call
> to succeed so it bails out because of the error.
> 
> Reading the trace and the msdn docs about NetUserModalsGet, vcsetup is
> calling with the level parameter == 2 so it is requesting the domain
> name and identifier.
> 
> With the included patch, I have stubbed the structure of the 4 levels
> that can be queried, but I haven't written the code to handle them
> yet.  If anyone has any information or links that will enlighten me
> about netapi32 or anything pertaining to this matter, I would greatly
> appreciate it.

I see [1] you've tried to implement the case of NetUserModalsGet()  
functionality where level == 2, also.  Thanks, I need it, too.  AFAIK it
would suffice only to copy information pointed by the
*PPOLICY_PRIMARY_DOMAIN_INFO struct to the *PUSER_MODALS_INFO_2 struct for
that, while you have done something very complex IMHO:

-NET_API_STATUS WINAPI NetUserModalsGet(LPCWSTR szServer, DWORD level, LPBYTE *pbuffer)
+NET_API_STATUS WINAPI NetUserModalsGet(LPCWSTR server, DWORD level, LPBYTE *bufptr)
+            ...
+            PPOLICY_ACCOUNT_DOMAIN_INFO domainInfo;
+            PSID domainIdentifier;
+            ...
+            domainNameLen = lstrlenW(domainInfo->DomainName.Buffer) + 1;
+            ...
+            NetApiBufferAllocate(domainNameLen * sizeof(WCHAR) + sizeof(PSID), (LPVOID *)bufptr);
+            
+            umi = (USER_MODALS_INFO_2 *) *bufptr;
+            umi->usrmod2_domain_name = (LPWSTR) (*bufptr + sizeof(USER_MODALS_INFO_2));
+            umi->usrmod2_domain_id = (PSID) (
+                 ((PBYTE) umi->usrmod2_domain_name) + domainNameLen * sizeof(WCHAR));
+            
+            lstrcpynW(umi->usrmod2_domain_name, domainInfo->DomainName.Buffer, domainNameLen);
+            
+            CopySid(sizeof(umi->usrmod2_domain_id), 
+                    umi->usrmod2_domain_id, domainIdentifier);

AFAICS:

1, there is big memory block allocated during the call to a
   NetApiBufferAllocate().  What for?  Why just not use a size of
   a USER_MODALS_INFO_2 ?  

   And yes, then you need to allocate the space twice more - for a string
   and for the new SID copy.  

2, maybe you want to allocate all needed space using a single buffer?
   Then what does this size mean:
   "domainNameLen * sizeof(WCHAR) + sizeof(PSID)" ?

3, the domainIdentifier variable is left uninitialized.

Does the patch work for you?  I know, instead of asking I should sit down
and just write some additional tests for the netapi32.dll.

What I cannot decide myself here (after having read the MSDN docs) is the
responsibility for freeing memory blocks, one allocated for the unicode
string (usrmod2_domain_name) and another one to hold the copy of SID
(usrmod2_domain_id).

MSDN tells only to free the memory allocated for the buffer (pointed by
the *bufptr).  Every sample of C code on the net I've found which calls
NetUserModalsGet() (and where the buffer contains some pointers by itself:
USER_MODALS_INFO_1, USER_MODALS_INFO_2) isn't freeing those internal
pointers: [2], [3], [4].

Does this mean the code (caller) leaks memory or it's just some automagic
used on the system side (callee) to free the memory (on real Windows)  
later?


> quote from MSDN:
> "The NetUserModalsGet function retrieves global information for all
> users and global groups in the security database, which is the
> security accounts manager (SAM) database or, in the case of domain
> controllers, the Active Directory."
> 
> Does wine have a security accounts manager or an Active Directory?

Good q.  Will someone answer it, please?


[1] http://www.winehq.org/hypermail/wine-patches/2004/08/0003.html
[2] http://www.faqchest.com/msdn/ATL/atl-99/atl-9901/atl-990100/atl99012521_19847.html
[3] http://66.102.11.104/search?q=cache:www.ntdev.org/archive/ntdev9807/msg0256.html+NetUserModalsGet+USER_MODALS_INFO_2+NetApiBufferFree
[4] http://66.102.11.104/search?q=cache:pintday.org/downloads/enum_tar.gz+NetUserModalsGet+PUSER_MODALS_INFO_1+NetApiBufferFree




More information about the wine-devel mailing list