示例#1
0
        // Token: 0x06002331 RID: 9009 RVA: 0x000A4B58 File Offset: 0x000A2D58
        public static void GetShareInfoWithSecurity(string serverName, string shareName, out string sharePath, out string shareRemark, out uint shareType, out int sharePermissions, out int shareMaxUses, out byte[] securityDescriptor)
        {
            IntPtr zero = IntPtr.Zero;

            securityDescriptor = null;
            try
            {
                uint num = NetShare.NetShareGetInfo(serverName, shareName, 502, out zero);
                if (num != 0U)
                {
                    ExTraceGlobals.NetShareTracer.TraceError <uint, string, string>(0L, "NetShareGetInfo error status: {0} for {1} {2}", num, serverName ?? "<null>", shareName);
                    throw new Win32Exception((int)num);
                }
                ExTraceGlobals.NetShareTracer.TraceDebug <uint, string, string>(0L, "GetShareInfo success status: {0} for {1} {2}", num, serverName ?? "<null>", shareName);
                NetShare.SHARE_INFO_502 share_INFO_ = (NetShare.SHARE_INFO_502)Marshal.PtrToStructure(zero, typeof(NetShare.SHARE_INFO_502));
                sharePath        = share_INFO_.Path;
                shareRemark      = share_INFO_.Remark;
                shareType        = share_INFO_.Type;
                sharePermissions = share_INFO_.Permissions;
                shareMaxUses     = share_INFO_.Max_uses;
                if (share_INFO_.Security_descriptor != IntPtr.Zero)
                {
                    uint securityDescriptorLength = NetShare.GetSecurityDescriptorLength(share_INFO_.Security_descriptor);
                    if (!NetShare.IsValidSecurityDescriptor(share_INFO_.Security_descriptor))
                    {
                        ExTraceGlobals.NetShareTracer.TraceDebug <string, string>(0L, "GetShareInfo : \\\\{1}\\{2} has an invalid security descriptor", serverName, shareName);
                    }
                    securityDescriptor = new byte[securityDescriptorLength];
                    Marshal.Copy(share_INFO_.Security_descriptor, securityDescriptor, 0, (int)securityDescriptorLength);
                }
            }
            finally
            {
                if (zero != IntPtr.Zero)
                {
                    uint num = NetShare.NetApiBufferFree(zero);
                    if (num != 0U)
                    {
                        throw new Win32Exception((int)num);
                    }
                }
            }
        }
示例#2
0
 private static extern uint NetShareAdd([MarshalAs(UnmanagedType.LPWStr)] string servername, int level, ref NetShare.SHARE_INFO_502 buf, out int paramNumber);
示例#3
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);
                }
            }
        }