Skip to content

Commit 3c4db91

Browse files
committed
Prep for 1.0.0.1 release
1 parent b5cdf25 commit 3c4db91

File tree

7 files changed

+64
-29
lines changed

7 files changed

+64
-29
lines changed

nmf-view/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@
1111
[assembly: AssemblyCulture("")]
1212
[assembly: ComVisible(false)]
1313

14-
[assembly: AssemblyVersion("1.0.0.0")]
15-
[assembly: AssemblyFileVersion("1.0.0.0")]
14+
[assembly: AssemblyVersion("1.0.0.1")]

nmf-view/Utilities.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Microsoft.Win32;
2+
using System;
23
using System.Diagnostics;
34
using System.Runtime.InteropServices;
45
using System.Windows.Forms;
@@ -30,5 +31,21 @@ internal static void OpenRegeditTo(string registryKeyPath)
3031
/* User may abort */
3132
}
3233
}
34+
35+
/// <summary>
36+
/// Open Windows Explorer with the specified file selected.
37+
/// </summary>
38+
/// <param name="manifestFilename"></param>
39+
internal static void OpenExplorerTo(string manifestFilename)
40+
{
41+
try
42+
{
43+
Process.Start("explorer.exe", $"/select,\"{manifestFilename}\"");
44+
}
45+
catch
46+
{
47+
/* User may abort */
48+
}
49+
}
3350
}
3451
}

nmf-view/frmMain.Designer.cs

Lines changed: 12 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nmf-view/frmMain.cs

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ private async Task MessageShufflerForExtension()
190190
string sNewBody = await response.Content.ReadAsStringAsync();
191191
if (!sNewBody.Contains("Fiddler Echo"))
192192
{
193+
log("Replacing message body with overridden text from Fiddler.");
193194
sMessage = sNewBody;
194195
}
195196
}
@@ -199,11 +200,13 @@ private async Task MessageShufflerForExtension()
199200
log($"Call to Fiddler failed: {e.Message}");
200201
}
201202
}
203+
202204
if (oSettings.bReflectToExtension &&
203205
(sMessage.Length < (1024 * 1024))) // Don't reflect messages over 1mb. They're illegal!
204206
{
205207
await WriteToExtension(sMessage);
206208
}
209+
207210
if (null != oSettings.strmToApp)
208211
{
209212
await WriteToApp(sMessage);
@@ -281,6 +284,7 @@ private async Task MessageShufflerForApp()
281284
string sNewBody = await response.Content.ReadAsStringAsync();
282285
if (!sNewBody.Contains("Fiddler Echo"))
283286
{
287+
log("Replacing message body with overridden text from Fiddler.");
284288
sMessage = sNewBody;
285289
}
286290
}
@@ -290,6 +294,7 @@ private async Task MessageShufflerForApp()
290294
log($"Call to Fiddler failed: {e.Message}");
291295
}
292296
}
297+
293298
if (null != oSettings.strmToExt)
294299
{
295300
await WriteToExtension(sMessage);
@@ -352,6 +357,10 @@ private void frmMain_Load(object sender, EventArgs e)
352357
);
353358
tcApp.SelectedTab = pageAbout;
354359
}
360+
else
361+
{
362+
log($"extension: {oSettings.sExtensionID}");
363+
}
355364
if (arrArgs.Length > 2)
356365
{
357366
// The parent-window value is only non-zero when the calling context is not a background script.
@@ -368,9 +377,11 @@ private void frmMain_Load(object sender, EventArgs e)
368377
toolTip1.SetToolTip(pbApp, $"Click to set the ClientHandler to another instance of this app.");
369378
log("Listening for messages...");
370379

371-
// clbOptions.SetItemChecked(1, true); Fiddler
372-
clbOptions.SetItemChecked(2, true);
373-
clbOptions.SetItemChecked(3, true);
380+
clbOptions.SetItemChecked(2, true); // Propagate closures
381+
clbOptions.SetItemChecked(3, true); // Record bodies
382+
string sCurrentExe = Application.ExecutablePath;
383+
if (sCurrentExe.Contains(".fiddler.")) clbOptions.SetItemChecked(1, true);
384+
if (sCurrentExe.Contains(".log.")) clbOptions.SetItemChecked(4, true);
374385

375386
if (oSettings.sExtensionID != "unknown") ConnectMostLikelyApp();
376387
WaitForMessages();
@@ -425,8 +436,9 @@ private void pbApp_Click(object sender, EventArgs e)
425436
private bool ConnectMostLikelyApp()
426437
{
427438
// If we are RealHost.proxy.exe, then see whether RealHost.exe exists, and if so, use that.
428-
string sCurrentExe = Application.ExecutablePath;
429-
if (sCurrentExe.IndexOf("proxy.", StringComparison.OrdinalIgnoreCase) > -1)
439+
// Remove any option flags in the command line.
440+
string sCurrentExe = Application.ExecutablePath.Replace(".log", string.Empty).Replace(".fiddler", string.Empty);
441+
if (sCurrentExe.Contains(".proxy"))
430442
{
431443
string sCandidate = sCurrentExe.Replace(".proxy", string.Empty);
432444
log($"Checking for {sCandidate}...");
@@ -688,18 +700,30 @@ private void lvHosts_KeyDown(object sender, KeyEventArgs e)
688700
(sender as HostListView).SelectAll();
689701
return;
690702
}
703+
if ((e.Modifiers == Keys.Alt) && e.KeyCode == Keys.Enter)
704+
{
705+
e.SuppressKeyPress = true;
706+
ShowSelectedManifestInExplorer();
707+
return;
708+
}
691709
}
692710

693711
private void lvHosts_MouseDoubleClick(object sender, MouseEventArgs e)
694712
{
695713
if ((Control.ModifierKeys == Keys.Alt) && (lvHosts.SelectedItems.Count == 1))
696714
{
697-
ListViewItem oLVI = lvHosts.SelectedItems[0];
698-
RegisteredHosts.HostEntry oHE = (RegisteredHosts.HostEntry)oLVI.Tag;
699-
Utilities.OpenRegeditTo(oHE.RegistryKeyPath);
715+
ShowSelectedManifestInExplorer();
700716
}
701717
}
702718

719+
private void ShowSelectedManifestInExplorer()
720+
{
721+
ListViewItem oLVI = lvHosts.SelectedItems[0];
722+
RegisteredHosts.HostEntry oHE = (RegisteredHosts.HostEntry)oLVI.Tag;
723+
Utilities.OpenExplorerTo(oHE.ManifestFilename);
724+
// Utilities.OpenRegeditTo(oHE.RegistryKeyPath);
725+
}
726+
703727
private void frmMain_FormClosed(object sender, FormClosedEventArgs e)
704728
{
705729
detachApp();

nmf-view/frmMain.resx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,6 @@
190190
<data name="lblQuickStart.Text" xml:space="preserve">
191191
<value>QuickStart: Native Messaging allows a web browser extension to send and receive messages from an application running outside of the browser's sandbox. To do so, the browser extension calls connectNative() to launch the application. After the application is launched, the extension and application can communicate by passing length-prefixed UTF-8 JSON-encoded messages between each other. This Meddler application can inject itself into that process, such that the browser will create it instead of the Native Message Host application. This app with then spawn that app and shuffle messages back and forth between the extension and the app, logging each message and optionally modifying it.</value>
192192
</data>
193-
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
194-
<value>17, 17</value>
195-
</metadata>
196193
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
197194
<value>
198195
AAABAAQAMDAAAAEAIACoJQAARgAAACAgAAABACAAqBAAAO4lAAAYGAAAAQAgAIgJAACWNgAAEBAAAAEA

nmf-view/nmf-view.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
<Compile Include="Utilities.cs" />
6969
<EmbeddedResource Include="frmMain.resx">
7070
<DependentUpon>frmMain.cs</DependentUpon>
71+
<SubType>Designer</SubType>
7172
</EmbeddedResource>
7273
<EmbeddedResource Include="Properties\Resources.resx">
7374
<Generator>ResXFileCodeGenerator</Generator>

sample-host/manifest.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
{
22
"name": "com.bayden.nmf.demo",
3-
"hack_name": "com.microsoft.browsercore",
43
"description": "NativeMessaging Meddler Demo Extension",
54
"path": "c:\\src\\nm\\nmf-view\\bin\\release\\RealNMHostApp.proxy.exe",
65
"type": "stdio",
76
"allowed_origins": [
8-
"chrome-extension://aalonnpchfmkpopkohiccmghgkipcjcb/",
9-
"chrome-extension://ppnbnpeolgkicgegkbkbjmhlideopiji/",
10-
"chrome-extension://ndjpnladcallmjemlbaebfadecfhkepb/",
11-
"chrome-extension://gggmmkjegpiggikcnhidnjjhmicpibll/"
7+
"chrome-extension://aalonnpchfmkpopkohiccmghgkipcjcb/"
128
]
139
}

0 commit comments

Comments
 (0)