first commit

This commit is contained in:
2026-01-07 11:33:05 +08:00
commit fc54ffd43b
215 changed files with 31856 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
using System.Drawing;
namespace EmoneyInteceptor.Fiddler.Interfaces
{
/// <summary>
/// 为插件提供 fiddler 布局相关的支持
/// </summary>
internal interface IFiddlerLayout
{
/// <summary>
/// fiddler tab view 尺寸变化时调用。
/// </summary>
/// <param name="size"></param>
void OnTabViewSizeChanged(Size size);
}
}

View File

@@ -0,0 +1,9 @@
using EmoneyInteceptor.Fiddler.Models;
using System.Collections.Generic;
namespace EmoneyInteceptor.Fiddler.Interfaces
{
public interface IFiddlerViewProvider
{
IList<FiddlerTabPage> BuildFiddlerTabPages();
}
}

View File

@@ -0,0 +1,62 @@
using Fiddler;
using EmoneyInteceptor.Fiddler.Interfaces;
namespace EmoneyInteceptor.Fiddler.Models
{
/// <summary>
/// Fiddler 插件应用的入口
/// </summary>
public abstract class FiddlerPluginApplication : IAutoTamper3
{
public virtual void OnLoad()
{
IFiddlerViewProvider viewProvider = GetFiddlerViewProvider();
if (viewProvider != null)
{
PluginViewController.InsertFiddlerTabPage(viewProvider);
}
}
public abstract IFiddlerViewProvider GetFiddlerViewProvider();
public virtual void OnBeforeUnload()
{
}
public virtual void AutoTamperRequestBefore(Session oSession)
{
}
public virtual void AutoTamperRequestAfter(Session oSession)
{
}
public virtual void AutoTamperResponseBefore(Session oSession)
{
}
public virtual void AutoTamperResponseAfter(Session oSession)
{
}
public virtual void OnBeforeReturningError(Session oSession)
{
}
public virtual void OnPeekAtResponseHeaders(Session oSession)
{
}
public virtual void OnPeekAtRequestHeaders(Session oSession)
{
}
}
}

View File

@@ -0,0 +1,35 @@
using System;
using Fiddler;
namespace EmoneyInteceptor.Fiddler.Models
{
public class FiddlerTabPage
{
/// <summary>
/// 获取 Fiddler Tab 标签页的 Title。
/// </summary>
public string TabTitle { get; }
/// <summary>
/// 获取或设置 Fiddler Tab 标签页的 Icon。
/// </summary>
public SessionIcons TabIcon { get; set; } = SessionIcons.Silverlight;
/// <summary>
/// 获取 Fiddler Tab 标签页内的 UserControl。
/// </summary>
public System.Windows.Forms.UserControl WinFormUserControl { get; }
public FiddlerTabPage(string tabTitle, System.Windows.Forms.UserControl winFormUserControl)
{
if (string.IsNullOrWhiteSpace(tabTitle))
{
throw new ArgumentNullException(nameof(tabTitle));
}
TabTitle = tabTitle;
WinFormUserControl = winFormUserControl ?? throw new ArgumentNullException(nameof(winFormUserControl));
}
}
}

View File

@@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using Fiddler;
using EmoneyInteceptor.Fiddler.Interfaces;
using EmoneyInteceptor.Fiddler.Models;
using EmoneyInteceptor.Emoney.Controls;
// is required
[assembly: RequiredVersion("4.5.1.2")]
namespace FiddlerPlugin.Fiddler.Models
{
public class EmoneyPlugin : FiddlerPluginApplication, IFiddlerViewProvider, IResponseInspector2, IWSMInspector
{
public HTTPResponseHeaders headers { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public byte[] body { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public bool bDirty => throw new NotImplementedException();
public bool bReadOnly { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public override void OnLoad()
{
FiddlerApplication.Log.LogString("Load MyFiddlerFiddlerPlugin");
// base.OnLoad() is required
base.OnLoad();
}
public override IFiddlerViewProvider GetFiddlerViewProvider()
{
return this;
}
public override void AutoTamperRequestAfter(Session oSession)
{
// do your work
}
public IList<FiddlerTabPage> BuildFiddlerTabPages()
{
string title = "益盟辅助";
EmoneyTabControl control = new EmoneyTabControl();
FiddlerApplication.OnWebSocketMessage += control.OnWebSocketMessage;
FiddlerApplication.BeforeResponse += control.BeforeResponse;
FiddlerApplication.BeforeRequest += control.BeforeRequest;
FiddlerTabPage fiddlerTabPage = new FiddlerTabPage(title, control);
return new List<FiddlerTabPage>()
{
fiddlerTabPage
};
}
public void Clear()
{
throw new NotImplementedException();
}
public void AssignMessage(WebSocketMessage oWSM)
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using Fiddler;
using EmoneyInteceptor.Fiddler.Interfaces;
namespace EmoneyInteceptor.Fiddler.Models
{
internal class PluginViewController
{
private static readonly IList<IFiddlerLayout> FiddlerLayoutViews = new List<IFiddlerLayout>();
public static void InsertFiddlerTabPage(IFiddlerViewProvider fiddlerViewProvider)
{
// 提供 fiddler 窗口变化的支持
FiddlerApplication.UI.tabsViews.SizeChanged += TabsViewsOnSizeChanged;
foreach (FiddlerTabPage fiddlerTabPage in fiddlerViewProvider.BuildFiddlerTabPages())
{
InsertFiddlerTabPage(fiddlerTabPage);
}
}
private static void InsertFiddlerTabPage(FiddlerTabPage fiddlerTabPage)
{
// new tab
System.Windows.Forms.TabPage tabPage = new System.Windows.Forms.TabPage(fiddlerTabPage.TabTitle) { ImageIndex = (int)fiddlerTabPage.TabIcon };
if (fiddlerTabPage.WinFormUserControl != null)
{
InsertWinFormTabPage(tabPage, fiddlerTabPage.WinFormUserControl);
}
UpdateViewSize();
}
private static void InsertWinFormTabPage(System.Windows.Forms.TabPage tabPage, System.Windows.Forms.UserControl userControl)
{
// add view to tab
tabPage.Controls.Add(userControl);
// add tab to fiddler
FiddlerApplication.UI.tabsViews.TabPages.Add(tabPage);
if (userControl is IFiddlerLayout layout)
{
FiddlerLayoutViews.Add(layout);
}
}
private static void TabsViewsOnSizeChanged(object sender, EventArgs e)
{
UpdateViewSize();
}
private static void UpdateViewSize()
{
System.Drawing.Size size = FiddlerApplication.UI.tabsViews.Size;
foreach (IFiddlerLayout view in FiddlerLayoutViews)
{
view.OnTabViewSizeChanged(size);
}
}
}
}