Esempio n. 1
0
        // Token: 0x06002334 RID: 9012 RVA: 0x000A4E90 File Offset: 0x000A3090
        internal static SHARE_INFO_503[] GetScopedShareInfo(string serverName, string shareName)
        {
            NetShare.SERVER_TRANSPORT_INFO2[] serverTransports = NetShare.GetServerTransports(serverName);
            if (serverTransports != null)
            {
                Dictionary <string, SHARE_INFO_503> dictionary = new Dictionary <string, SHARE_INFO_503>(3);
                foreach (NetShare.SERVER_TRANSPORT_INFO2 server_TRANSPORT_INFO in serverTransports)
                {
                    if ((server_TRANSPORT_INFO.Flags & 4U) != 0U)
                    {
                        SHARE_INFO_503[] array2;
                        uint             num = NetShare.EnumScopedShares(server_TRANSPORT_INFO.Networkaddress, out array2);
                        if (num != 0U)
                        {
                            ExTraceGlobals.NetShareTracer.TraceError <uint, string>(0L, "EnumScopedShares() error status: {0} for {1}", num, server_TRANSPORT_INFO.Networkaddress);
                            throw new Win32Exception((int)num);
                        }
                        foreach (SHARE_INFO_503 value in array2)
                        {
                            if (Cluster.StringIEquals(value.Netname, shareName))
                            {
                                dictionary[value.Servername] = value;
                            }
                        }
                    }
                }
                if (dictionary.Count != 0)
                {
                    Dictionary <string, SHARE_INFO_503> .ValueCollection values = dictionary.Values;
                    SHARE_INFO_503[] array4 = new SHARE_INFO_503[values.Count];
                    values.CopyTo(array4, 0);
                    return(array4);
                }
            }
            string path;
            string remark;
            uint   type;
            int    permissions;
            int    max_uses;

            NetShare.GetShareInfo(serverName, shareName, out path, out remark, out type, out permissions, out max_uses);
            return(new SHARE_INFO_503[]
            {
                new SHARE_INFO_503
                {
                    Netname = shareName,
                    Type = type,
                    Remark = remark,
                    Permissions = permissions,
                    Max_uses = max_uses,
                    Current_uses = 0,
                    Path = path,
                    Passwd = null,
                    Servername = "*",
                    Reserved = 0,
                    Security_descriptor = IntPtr.Zero
                }
            });
        }
Esempio n. 2
0
        // Token: 0x06002339 RID: 9017 RVA: 0x000A51D0 File Offset: 0x000A33D0
        private static SHARE_INFO_503[] PtrToShareInfo503(IntPtr shareInfoPtr, uint entriesRead)
        {
            SHARE_INFO_503[] array = new SHARE_INFO_503[entriesRead];
            int num  = Marshal.SizeOf(typeof(SHARE_INFO_503));
            int num2 = 0;

            while ((long)num2 < (long)((ulong)entriesRead))
            {
                IntPtr ptr = (IntPtr)(shareInfoPtr.ToInt64() + (long)(num2 * num));
                array[num2] = (SHARE_INFO_503)Marshal.PtrToStructure(ptr, typeof(SHARE_INFO_503));
                num2++;
            }
            return(array);
        }
Esempio n. 3
0
        // Token: 0x06002333 RID: 9011 RVA: 0x000A4DE0 File Offset: 0x000A2FE0
        internal static uint EnumScopedShares(string networkAddress, out SHARE_INFO_503[] shareInfos)
        {
            uint   num  = 0U;
            IntPtr zero = IntPtr.Zero;

            shareInfos = null;
            try
            {
                uint num2 = 0U;
                uint num3;
                uint num4;
                num = NetShare.NetShareEnum(networkAddress, 503U, out zero, uint.MaxValue, out num3, out num4, ref num2);
                if (num == 124U)
                {
                    shareInfos = new SHARE_INFO_503[0];
                    return(num);
                }
                if (num != 0U)
                {
                    ExTraceGlobals.NetShareTracer.TraceError <uint, string>(0L, "NetShareEnum() error status: {0} for {1}", num, networkAddress);
                    throw new Win32Exception((int)num);
                }
                shareInfos = NetShare.PtrToShareInfo503(zero, num3);
                ExTraceGlobals.NetShareTracer.TraceDebug <string, uint>(0L, "NetShareEnum( networkAddress={0} ) found {1} shares.", networkAddress, num3);
            }
            finally
            {
                if (zero != IntPtr.Zero)
                {
                    num = NetShare.NetApiBufferFree(zero);
                    if (num != 0U)
                    {
                        throw new Win32Exception((int)num);
                    }
                }
            }
            return(num);
        }
Esempio n. 4
0
 private static extern uint NetShareAdd([MarshalAs(UnmanagedType.LPWStr)] string servername, int level, ref SHARE_INFO_503 buf, out int paramNumber);
Esempio n. 5
0
        // Token: 0x0600232E RID: 9006 RVA: 0x000A4740 File Offset: 0x000A2940
        public static void AddShare(string serverName, string scopeName, string shareName, string sharePath, string shareRemark, byte[] securityDescriptor, out int paramNumber)
        {
            IntPtr intPtr = IntPtr.Zero;

            paramNumber = 0;
            try
            {
                if (securityDescriptor != null && securityDescriptor.Length > 0)
                {
                    intPtr = Marshal.AllocHGlobal(securityDescriptor.Length);
                    Marshal.Copy(securityDescriptor, 0, intPtr, securityDescriptor.Length);
                }
                uint num = 87U;
                if (NetShare.IsLonghornAndAbove())
                {
                    SHARE_INFO_503 share_INFO_ = default(SHARE_INFO_503);
                    share_INFO_.Netname             = shareName;
                    share_INFO_.Type                = 0U;
                    share_INFO_.Remark              = shareRemark;
                    share_INFO_.Permissions         = 1;
                    share_INFO_.Max_uses            = -1;
                    share_INFO_.Current_uses        = 0;
                    share_INFO_.Path                = sharePath;
                    share_INFO_.Passwd              = null;
                    share_INFO_.Servername          = scopeName;
                    share_INFO_.Reserved            = 0;
                    share_INFO_.Security_descriptor = intPtr;
                    num = NetShare.NetShareAdd(serverName, 503, ref share_INFO_, out paramNumber);
                }
                if (num == 87U)
                {
                    NetShare.SHARE_INFO_502 share_INFO_2 = default(NetShare.SHARE_INFO_502);
                    share_INFO_2.Netname             = shareName;
                    share_INFO_2.Type                = 0U;
                    share_INFO_2.Remark              = shareRemark;
                    share_INFO_2.Permissions         = 1;
                    share_INFO_2.Max_uses            = -1;
                    share_INFO_2.Current_uses        = 0;
                    share_INFO_2.Path                = sharePath;
                    share_INFO_2.Passwd              = null;
                    share_INFO_2.Reserved            = 0;
                    share_INFO_2.Security_descriptor = intPtr;
                    num = NetShare.NetShareAdd(serverName, 502, ref share_INFO_2, out paramNumber);
                }
                if (num != 0U)
                {
                    ExTraceGlobals.NetShareTracer.TraceError(0L, "NetShareAdd error status: {0}, paramNumber: {1} for serverName={2}, scopeName={3}, shareName={4}, sharePath={5}", new object[]
                    {
                        num,
                        paramNumber,
                        serverName,
                        scopeName,
                        shareName,
                        sharePath
                    });
                    throw new Win32Exception((int)num);
                }
                ExTraceGlobals.NetShareTracer.TraceDebug(0L, "NetShareAdd success status: {0}, paramNumber: {1} for serverName={2}, scopeName={3}, shareName={4}, sharePath={5}", new object[]
                {
                    num,
                    paramNumber,
                    serverName,
                    scopeName,
                    shareName,
                    sharePath
                });
                ExTraceGlobals.PFDTracer.TracePfd(0L, "PFD CRS {0} NetShareAdd success status: {1}, paramNumber: {2} for serverName={3}, scopeName={4}, shareName={5}, sharePath={6}", new object[]
                {
                    26587,
                    num,
                    paramNumber,
                    serverName,
                    scopeName,
                    shareName,
                    sharePath
                });
            }
            finally
            {
                if (intPtr != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(intPtr);
                }
            }
        }