Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wip nov0caina #19

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions SelfishNetV3/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
<startup>

<supportedRuntime version="v2.0.50727"/></startup>

</configuration>
34 changes: 24 additions & 10 deletions SelfishNetV3/ArpForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

143 changes: 121 additions & 22 deletions SelfishNetV3/ArpForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@

namespace SelfishNetv3
{
#pragma warning disable CS1591 // Falta el comentario XML para el tipo o miembro visible públicamente
#pragma warning disable // Falta el comentario XML para el tipo o miembro visible públicamente
public delegate void delegateOnNewPC(PC pc);

public delegate void DelUpdateName(PC pc, string str);
public partial class ArpForm : Form
{

public int timerStatCount;
public Driver driver;
public PcList pcs;
public CArp cArp;
public CArp cArp;
public CAdapter cAdapter;
public byte[] routerIP;
public object[] resolvState;
Expand All @@ -48,9 +48,12 @@ public void licenseAccepted()
{
CAdapter cadapter = new CAdapter();
this.cAdapter = cadapter;
cadapter.Show((IWin32Window)this);
if (!minimized) cadapter.Show((IWin32Window)this);
}
}
bool first_start;
bool minimized;

public void NicIsSelected(NetworkInterface nic)
{
this.pcs = new PcList();
Expand Down Expand Up @@ -99,19 +102,19 @@ private void EndResolvCallBack(IAsyncResult re)
try
{
str = Dns.EndResolve(re).HostName;
if (str == (string)null)
str = "noname";
object[] objArray = new object[2];
this.resolvState = objArray;
objArray[0] = (object)asyncState;
this.resolvState[1] = (object)str;
this.Invoke((Delegate)new DelUpdateName(this.updateTreeViewNameCallBack), this.resolvState);
if (str == (string)null)
str = "noname";
object[] objArray = new object[2];
this.resolvState = objArray;
objArray[0] = (object)asyncState;
this.resolvState[1] = (object)str;
this.Invoke((Delegate)new DelUpdateName(this.updateTreeViewNameCallBack), this.resolvState);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}

}

private void updateTreeViewNameCallBack(PC pc, string str)
Expand Down Expand Up @@ -303,6 +306,7 @@ private void TreeGridView1_CellValueChanged(object sender, DataGridViewCellEvent
return;
for (int index = 0; index < 35; ++index)
this.cArp.UnSpoof(ipAddress1, new IPAddress(this.cArp.routerIP));

}
catch (Exception ex)
{
Expand All @@ -312,6 +316,20 @@ private void TreeGridView1_CellValueChanged(object sender, DataGridViewCellEvent

private unsafe void ArpForm_Load(object sender, EventArgs e)
{

if (args.Length > 1)
{
if (args[1] == "minimize")
{
first_start = true;
minimized = true;
}
}


this.Text = "SelfishNet v" + Application.ProductVersion.ToString() + " (Minimum By Abdou.Kouach)";
this.Icon = SelfishNetv3.Properties.Resources.SN2_result;
SelfishNetTrayIcon.Icon = SelfishNetv3.Properties.Resources.SN2_result;
if ((IntPtr)this.driver.openDeviceDriver((sbyte*)(void*)Marshal.StringToHGlobalAnsi("npf")) == IntPtr.Zero)
{
if (System.IO.File.Exists("license.txt"))
Expand Down Expand Up @@ -419,7 +437,7 @@ private void TimerSpoof_Tick(object sender, EventArgs e)
while (index < this.treeGridView1.Nodes[0].Nodes.Count);
}




private void ViewMenuIP_CheckStateChanged(object sender, EventArgs e)
Expand Down Expand Up @@ -469,35 +487,116 @@ private void SelfishNetTrayIcon_DoubleClick(object sender, EventArgs e)

}

string[] args = Environment.GetCommandLineArgs();

private void SelfishNetTrayIcon_MouseDoubleClick(object sender, MouseEventArgs e)
{
Show();
this.WindowState = FormWindowState.Normal;
this.WindowState = FormWindowState.Normal;
}

private void ArpForm_Resize(object sender, EventArgs e)
{
if (WindowState == FormWindowState.Minimized) Hide();
this.SelfishNetTrayIcon.ShowBalloonTip(2000);
if (WindowState == FormWindowState.Minimized)
{
Hide();
}
else
{

if (first_start)
{

CAdapter cadapter = new CAdapter();
this.cAdapter = cadapter;
cadapter.Show((IWin32Window)this);
first_start = false;
}


}
//this.SelfishNetTrayIcon.ShowBalloonTip(2000);
}

private void ExitToolStripMenuItem_Click(object sender, EventArgs e)
{
var rs = MessageBox.Show(this, "Quit?", "Quit", MessageBoxButtons.YesNo);
if (rs == DialogResult.Yes) Environment.Exit(0);
this.Close();
//var rs = MessageBox.Show(this, "Quit?", "Quit", MessageBoxButtons.YesNo);
//if (rs == DialogResult.Yes) Environment.Exit(0);
}

private void ShowToolStripMenuItem_Click(object sender, EventArgs e)
{
Show();
this.WindowState = FormWindowState.Normal;
}

}

private void ToolStripButton7_Click(object sender, EventArgs e)
{
WindowState = FormWindowState.Maximized;
}


private void ArpForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (!systemShutdown)
{

System.Windows.Forms.DialogResult result = MessageBox.Show("Are you sure you want to close the App?", "Application Closing!", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
switch (result)
{
case System.Windows.Forms.DialogResult.OK:
if (WindowState == FormWindowState.Minimized)
{
Show();
}
ToolStripButton3_Click(toolStripButton3, new EventArgs());
SelfishNetTrayIcon.Dispose();
Environment.Exit(0);
break;
}
e.Cancel = true;
}
else
{
ToolStripButton3_Click(toolStripButton3, new EventArgs());
SelfishNetTrayIcon.Dispose();
Environment.Exit(0);

}

}

private void ArpForm_Shown(object sender, EventArgs e)
{
string[] args = Environment.GetCommandLineArgs();
if ((args.Length > 1))
{
minimized = true;
if (args[1] == "minimize") this.WindowState = FormWindowState.Minimized;
}
Opacity = 100;
}



private static int WM_QUERYENDSESSION = 0x11;
public static bool systemShutdown = false;
protected override void WndProc(ref System.Windows.Forms.Message m)
{
if (m.Msg == WM_QUERYENDSESSION)
{
//MessageBox.Show("queryendsession: this is a logoff, shutdown, or reboot");
systemShutdown = true;
}

// If this is WM_QUERYENDSESSION, the closing event should be
// raised in the base WndProc.
base.WndProc(ref m);

} //WndProc

#pragma warning restore // Falta el comentario XML para el tipo o miembro visible públicamente
}
#pragma warning restore CS1591 // Falta el comentario XML para el tipo o miembro visible públicamente
}
}
Loading