Esempio n. 1
0
 protected override void internal_refill()
 {
     SHARE_INFO_1[] infos = WinApiNETwrapper.GetShareInfos_1(server_name);
     internal_list.Clear();
     foreach (SHARE_INFO_1 info in infos)
     {
         internal_list.Add(info, null);
     }
 }
Esempio n. 2
0
        private NETRESOURCE[] get_hidden_resources(NETRESOURCE res)
        {
            List <NETRESOURCE> ret = new List <NETRESOURCE>();

            try
            {
                string         server_name = res.lpRemoteName.TrimStart(new char[] { '\\' });
                SHARE_INFO_1[] net_shares  = WinApiNETwrapper.GetShareInfos_1(server_name);
                foreach (SHARE_INFO_1 info in net_shares)
                {
                    if (info.shi1_netname.EndsWith("$"))
                    {
                        NETRESOURCE hid_res = new NETRESOURCE();

                        if ((info.shi1_type & NetshareType.DEVICE) == NetshareType.DEVICE)
                        {
                            //IPC$
                            hid_res.dwDisplayType = ResourceDisplayType.GENERIC;
                            hid_res.dwType        = ResourceType.ANY;
                        }
                        else if ((info.shi1_type & NetshareType.PRINTQ) == NetshareType.PRINTQ)
                        {
                            hid_res.dwDisplayType = ResourceDisplayType.SHAREADMIN;
                            hid_res.dwType        = ResourceType.PRINT;
                        }
                        else if ((info.shi1_type & NetshareType.SPECIAL) == NetshareType.SPECIAL)
                        {
                            //C$
                            hid_res.dwDisplayType = ResourceDisplayType.SHAREADMIN;
                            hid_res.dwType        = ResourceType.DISK;
                        }

                        hid_res.lpComment    = info.shi1_remark;
                        hid_res.lpProvider   = res.lpProvider;
                        hid_res.lpRemoteName = string.Format(@"{0}\{1}", res.lpRemoteName, info.shi1_netname);
                        ret.Add(hid_res);
                    }
                }
            }
            catch (Exception) { }
            return(ret.ToArray());
        }
Esempio n. 3
0
        private void fill_share_page()
        {
            try
            {
                var share_splitted = resource_intern.lpRemoteName.Split
                                         (new char[] { System.IO.Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries);
                var share_info = WinApiNETwrapper.GetShareInfo_2(share_splitted[0], share_splitted[1]);

                textBoxShareType.Text        = share_info.shi2_type.ToString();
                textBoxShareComment.Text     = share_info.shi2_remark;
                textBoxSharePermissions.Text = share_info.shi2_permissions.ToString();
                textBoxShareMaxuses.Text     = share_info.shi2_max_uses.ToString();
                textBoxShareCurrentUses.Text = share_info.shi2_current_uses.ToString();
                textBoxSharePath.Text        = share_info.shi2_path;
            }
            catch (Exception ex)
            {
                errorProvider1.SetIconAlignment(textBoxShareType, ErrorIconAlignment.MiddleLeft);
                errorProvider1.SetError(textBoxShareType, ex.Message);
            }
        }
Esempio n. 4
0
        protected override void internal_refill()
        {
            List <SERVER_INFO_101> new_list = null;

            if (domain_name == null)
            {
                new_list = new List <SERVER_INFO_101>
                               (WinApiNETwrapper.GetServerInfos_101(NetserverEnumType.ALL));
            }
            else
            {
                new_list = new List <SERVER_INFO_101>
                               (WinApiNETwrapper.GetServerInfos_101(domain_name, NetserverEnumType.ALL));
            }

            internal_list.Clear();
            foreach (var info in new_list)
            {
                internal_list.Add(info, null);
            }
        }
Esempio n. 5
0
        private void fill_netserver_page()
        {
            try
            {
                var serv_info = WinApiNETwrapper.GetServerInfo_102(resource_intern.lpRemoteName);
                textBoxNetserverPlatformId.Text      = serv_info.sv102_platform_id.ToString();
                textBoxNetserverSoftwareType.Text    = IOhelper.NetserverTypeToString(serv_info.sv102_type);
                textBoxPlatformVersion.Text          = string.Format("{0}.{1}", serv_info.GetVersionMajor(), serv_info.sv102_version_minor);
                textBoxNetserverMaxUsers.Text        = serv_info.sv102_users.ToString();
                textBoxNetserverDisconnectTime.Text  = serv_info.sv102_disc.ToString();
                textBoxNetserverAnnounceTime.Text    = serv_info.sv102_announce.ToString();
                textBoxNetserverUsersPerLicense.Text = serv_info.sv102_licenses.ToString();
                textBoxNetserverUserPath.Text        = serv_info.sv102_userpath;
            }
            catch (Exception ex)
            {
                errorProvider1.SetIconAlignment(textBoxNetserverPlatformId, ErrorIconAlignment.MiddleLeft);
                errorProvider1.SetError(textBoxNetserverPlatformId, ex.Message);
            }

            try
            {
                var features = WinApiNETwrapper.GetComputerSupports(resource_intern.lpRemoteName);
                textBoxNetserverFeatures.Text = features.ToString();
            }
            catch (Exception ex)
            {
                errorProvider1.SetIconAlignment(textBoxNetserverFeatures, ErrorIconAlignment.MiddleLeft);
                errorProvider1.SetError(textBoxNetserverFeatures, ex.Message);
            }

            try
            {
                var dt = WinApiNETwrapper.GetServerTime(resource_intern.lpRemoteName);
                textBoxNetserverDatetime.Text = string.Format("{0} {1},{2}", dt.GetCurrentDatetime().ToLongDateString(), dt.GetCurrentDatetime().ToLongTimeString(), dt.GetCurrentDatetime().Millisecond);
                textBoxNetserverUptime.Text   = dt.GetUptime().ToString();
            }
            catch (Exception ex)
            {
                errorProvider1.SetIconAlignment(textBoxNetserverDatetime, ErrorIconAlignment.MiddleLeft);
                errorProvider1.SetError(textBoxNetserverDatetime, ex.Message);
            }

            //NET_DISPLAY_GROUP[] groups = WinApiNETwrapper.QueryDisplayInfoGroup(resource_intern.lpRemoteName);
            //NET_DISPLAY_MACHINE[] machines = WinApiNETwrapper.QueryDisplayInfoMachine(resource_intern.lpRemoteName);
            //NET_DISPLAY_USER[] users = WinApiNETwrapper.QueryDisplayInfoUser(resource_intern.lpRemoteName);

            try
            {
                var transports = WinApiNETwrapper.ServerTransportEnum_1(resource_intern.lpRemoteName);
                for (var i = 0; i < transports.Length; i++)
                {
                    var lvi = new ListViewItem();
                    lvi.Text = transports[i].svti1_transportname;
                    lvi.SubItems.Add(transports[i].TransportAddress);
                    lvi.SubItems.Add(transports[i].svti1_networkaddress);
                    lvi.SubItems.Add(transports[i].svti1_domain);
                    lvi.SubItems.Add(transports[i].svti1_numberofvcs.ToString());
                    listViewTransports.Items.Add(lvi);
                }
                listViewTransports.Dock = DockStyle.Fill;
            }
            catch (Exception ex)
            {
                errorProvider1.SetIconAlignment(listViewTransports, ErrorIconAlignment.MiddleLeft);
                errorProvider1.SetError(listViewTransports, ex.Message);
            }

            /* net sessions */
            errorProvider1.SetIconAlignment(listViewSessions, ErrorIconAlignment.MiddleLeft);
            Array sessions      = null;
            var   session_level = NetSessionEnumLevel.INFO_502;

            try
            {
                //try level 502
                sessions = WinApiNETwrapper.NetSessionEnum(resource_intern.lpRemoteName, null, null, session_level);
            }
            catch (Exception)
            {
                //if exception try level 10
                session_level = NetSessionEnumLevel.INFO_10;
                try
                {
                    sessions = WinApiNETwrapper.NetSessionEnum(resource_intern.lpRemoteName, null, null, session_level);
                }
                catch (Exception ex_10)
                {
                    errorProvider1.SetError(listViewSessions, ex_10.Message);
                }
            }
            if (sessions != null)
            {
                listViewSessions.Dock = DockStyle.Fill;
                for (var i = 0; i < sessions.Length; i++)
                {
                    var lvi = new ListViewItem();
                    switch (session_level)
                    {
                    case NetSessionEnumLevel.INFO_502:
                        var info_502 = (SESSION_INFO_502)sessions.GetValue(i);
                        lvi.Text = info_502.sesi502_cname;
                        lvi.SubItems.Add(info_502.sesi502_username);
                        lvi.SubItems.Add(info_502.sesi502_num_opens.ToString());
                        lvi.SubItems.Add(info_502.TimeActive.ToString());
                        lvi.SubItems.Add(info_502.TimeIdle.ToString());
                        lvi.SubItems.Add(info_502.sesi502_user_flags.ToString());
                        lvi.SubItems.Add(info_502.sesi502_cltype_name);
                        lvi.SubItems.Add(info_502.sesi502_transport);
                        break;

                    case NetSessionEnumLevel.INFO_10:
                        var info_10 = (SESSION_INFO_10)sessions.GetValue(i);
                        lvi.Text = info_10.sesi10_cname;
                        lvi.SubItems.Add(string.Empty);
                        lvi.SubItems.Add(string.Empty);
                        lvi.SubItems.Add(info_10.TimeActive.ToString());
                        lvi.SubItems.Add(info_10.TimeIdle.ToString());
                        lvi.SubItems.Add(string.Empty);
                        lvi.SubItems.Add(string.Empty);
                        lvi.SubItems.Add(string.Empty);
                        break;
                    }
                    listViewSessions.Items.Add(lvi);
                }
            }
            /* end of net sessions */

            /* open files */
            try
            {
                var files = WinApiNETwrapper.NetFileEnum(resource_intern.lpRemoteName, null, null, NetFileEnumLevel.INFO_3);
                listViewFiles.Dock = DockStyle.Fill;
                for (var i = 0; i < files.Length; i++)
                {
                    var f_info = (FILE_INFO_3)files.GetValue(i);
                    var lvi    = new ListViewItem();
                    lvi.Text = string.Format("0x{0:X}", f_info.fi3_id);
                    lvi.SubItems.Add(f_info.fi3_permission.ToString());
                    lvi.SubItems.Add(f_info.fi3_num_locks.ToString());
                    lvi.SubItems.Add(f_info.fi3_pathname);
                    lvi.SubItems.Add(f_info.fi3_username);
                    listViewFiles.Items.Add(lvi);
                }
            }
            catch (Exception ex_files)
            {
                errorProvider1.SetIconAlignment(listViewFiles, ErrorIconAlignment.MiddleLeft);
                errorProvider1.SetError(listViewFiles, ex_files.Message);
            }
            /* end of open files */
        }