Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
7908816
Made screen capture more stable. Fixed a memory leak.
sabaatworld Sep 10, 2017
4092f47
Fixed a memory leak. Improved ProtoClient Exception handling and overall
sabaatworld Sep 10, 2017
281f431
Fixed various bugs. Corrected issue with saving settings. Added
sabaatworld Sep 15, 2017
c3473eb
Change up some code. Fixed various possible memory leak situations.
sabaatworld Sep 15, 2017
9dd5447
Added DX11 screen capture
sabaatworld Sep 17, 2017
4d3916c
Improving Setup form. Added DX11 configuration options.
sabaatworld Sep 20, 2017
a99e8d4
Corrected app metadata. Added more explanation to DirectX options. Ad…
sabaatworld Sep 21, 2017
719698b
Set theme jekyll-theme-time-machine
sabaatworld Sep 22, 2017
ad61ada
Set theme jekyll-theme-hacker
sabaatworld Sep 22, 2017
a58ec19
Added more help content. Corrected Costura configuration. Update some
sabaatworld Sep 21, 2017
c4abcd4
Changed installer script to include new distribution point.
sabaatworld Sep 22, 2017
00c8545
Updated AssemblyInformation.cs
sabaatworld Sep 22, 2017
2fb4e48
Updated README.MD with the new configuration file example
sabaatworld Sep 22, 2017
b2e04b6
Updated release information
sabaatworld Sep 22, 2017
d87042c
Added more stuff to README
sabaatworld Sep 22, 2017
5de4fad
Added screenshots
sabaatworld Sep 22, 2017
cbd0d06
Fixed hardcoded settings for MaxFPS, Frame Capture Timeout. Reorganized
sabaatworld Sep 23, 2017
5bd2c00
Added option to configure user switch and system suspend detection. Made
sabaatworld Sep 24, 2017
a5eb261
Fixed Null object reference during initialization. Enabled re-init on
sabaatworld Oct 15, 2017
ed7e0a3
Added automatic update checks
sabaatworld Oct 17, 2017
8575479
Added Logging. Improved update check.
sabaatworld Oct 18, 2017
6a8db96
Added automatic settings upgrade. Updated application version to 2.3.
sabaatworld Nov 5, 2017
48a6741
Extracing screen capture task out into a separate class. Support
sabaatworld Nov 11, 2017
6d97ad4
Added high resolution icons. Fixed some issues with multiscreen code.
sabaatworld Nov 22, 2017
8fa5561
Added ability to define multiple Hyperion server configurations.
sabaatworld Nov 22, 2017
95fb802
Modifying Setup Form to support multiple monitor configuration. Fixed
sabaatworld Nov 25, 2017
56319a0
Added donation option
sabaatworld Nov 26, 2017
07d6dd8
Remove unnecessary files
sabaatworld Nov 26, 2017
6625dfe
Unmap resource after use
thymoze Jan 7, 2018
ad731bf
Bugfix for API server not starting
Jan 10, 2018
d1d9531
Bumped up version to 2.4. Catching exceptions during DX11 resource un…
sabaatworld Jan 17, 2018
b62a894
Update README.md
sabaatworld Jan 18, 2018
f1122f4
Added new Installation script. Updated Assembly information.
sabaatworld Jan 18, 2018
b5c5faa
Removed setup icon
sabaatworld Jan 18, 2018
c58993a
Corrected some logs. Fixed auto capture startup issue. Corrected exit
sabaatworld Jan 27, 2018
2c3b599
Corrected failure detection logic. Fixed race condition which caused
sabaatworld Jan 28, 2018
61f5658
Fixed resolution detection for secondary monitors
sabaatworld Oct 9, 2018
0fe645c
Added TLS 1.2 support for GitHub API
sabaatworld Oct 9, 2018
d3b3690
Update README.md
laurens94 Sep 26, 2019
31c9fa8
feat: upgrade to latest VS2019 and .NET4.8
xas May 20, 2020
70a2f8c
fix: cleanup SlimDx reference
xas May 21, 2020
432f1a5
New Icons. Removed donate form.
sabaatworld Nov 15, 2020
ce30d51
Added FlatBuffers support. Help rendered through markdown. Legacy
sabaatworld Nov 16, 2020
8f22d4d
Setup script changes. Settings bug fixes.
sabaatworld Nov 17, 2020
b195cc2
Fixed setup generator. Updated README.md. Bug Fixes.
sabaatworld Nov 18, 2020
422dffe
Update README
sabaatworld Nov 18, 2020
9e1e0f1
Updated README
sabaatworld Nov 18, 2020
fbb0e96
Deleted extra files
sabaatworld Jan 1, 2021
596c8ee
Accept API server connection from any host. Updated version to 2.8.
sabaatworld Jan 8, 2022
c417db1
Fix DX9 capture typo. Modified retry counts. No terminal window for A…
sabaatworld Jan 8, 2022
788b98d
Bump version to 2.9
sabaatworld Jan 8, 2022
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
13 changes: 11 additions & 2 deletions HyperionScreenCap.sln
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
# Visual Studio Version 17
VisualStudioVersion = 17.0.32014.148
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HyperionScreenCap", "HyperionScreenCap\HyperionScreenCap.csproj", "{9EC68860-AE7E-413F-A5A4-AC31B93912C2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9EC68860-AE7E-413F-A5A4-AC31B93912C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9EC68860-AE7E-413F-A5A4-AC31B93912C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9EC68860-AE7E-413F-A5A4-AC31B93912C2}.Debug|x86.ActiveCfg = Debug|x86
{9EC68860-AE7E-413F-A5A4-AC31B93912C2}.Debug|x86.Build.0 = Debug|x86
{9EC68860-AE7E-413F-A5A4-AC31B93912C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9EC68860-AE7E-413F-A5A4-AC31B93912C2}.Release|Any CPU.Build.0 = Release|Any CPU
{9EC68860-AE7E-413F-A5A4-AC31B93912C2}.Release|x86.ActiveCfg = Release|x86
{9EC68860-AE7E-413F-A5A4-AC31B93912C2}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {69DA975B-0B6F-429E-A703-7406407B070B}
EndGlobalSection
EndGlobal
175 changes: 135 additions & 40 deletions HyperionScreenCap/ApiServer.cs
Original file line number Diff line number Diff line change
@@ -1,92 +1,187 @@
using System;
using System.Diagnostics;
using System.Security.Principal;
using Grapevine.Interfaces.Server;
using Grapevine.Server;
using Grapevine.Server.Attributes;
using Grapevine.Shared;

using log4net;

namespace HyperionScreenCap
{
class ApiServer
{
private static readonly ILog LOG = LogManager.GetLogger(typeof(ApiServer));

private MainForm _mainForm;
private RestServer _server;

public ApiServer(MainForm mainForm)
{
_mainForm = mainForm;
}

public void StartServer(string hostname, string port)
{
try
{
if (_server == null)
LOG.Info("Checking if ACL URL is reserved");
if (!IsAclUrlReserved(hostname, port))
{
LOG.Info("ACL URL not reserved. Attempting to reserve.");
ReserveAclUrl(hostname, port);
}

if ( _server == null )
{
LOG.Info($"Starting API server: {hostname}:{port}");
_server = new RestServer
{
Host = hostname,
Port = port
};

var apiRoute = new Route(API);
_server.Router.Register(apiRoute);

_server.Start();
LOG.Info("API server started");
}
}
catch (Exception){
catch ( Exception ex )
{
LOG.Error("Failed to start API server", ex);
}
}

public void StopServer()
{
LOG.Info("Stopping API server");
_server?.Stop();
LOG.Info("API server stopped");
}

public void RestartServer(string hostname, string port)
{
LOG.Info("Restarting API server");
StopServer();
StartServer(hostname, port);
}

[RestResource]
public class Resources
/// <summary>
/// DO NOT RENAME THIS METHOD. The name is used in the reflection code above.
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
[RestRoute(HttpMethod = HttpMethod.GET, PathInfo = "/API")]
private IHttpContext API(IHttpContext context)
{
[RestRoute(HttpMethod = HttpMethod.GET, PathInfo = "/API")]
public IHttpContext API(IHttpContext context)
{
context.Response.ContentType = ContentType.TEXT;
string responseText = "No valid API command received.";
string command = context.Request.QueryString["command"] ?? "";
string force = context.Request.QueryString["force"] ?? "false";
LOG.Info("API server command received");
context.Response.ContentType = ContentType.TEXT;
string responseText = "No valid API command received.";
string command = context.Request.QueryString["command"] ?? "";
string force = context.Request.QueryString["force"] ?? "false";

if (!string.IsNullOrEmpty(command))
if ( !string.IsNullOrEmpty(command) )
{
LOG.Info($"Processing API command: {command}");
// Only process valid commands
if ( command == "ON" || command == "OFF" )
{
// Only process valid commands
if (command == "ON" || command == "OFF")
{

// Check for deactivate API between certain times
if (Settings.ApiExcludedTimesEnabled && force.ToLower() == "false")
// Check for deactivate API between certain times
if ( SettingsManager.ApiExcludedTimesEnabled && force.ToLower() == "false" )
{
if ( (DateTime.Now.TimeOfDay >= SettingsManager.ApiExcludeTimeStart.TimeOfDay &&
DateTime.Now.TimeOfDay <= SettingsManager.ApiExcludeTimeEnd.TimeOfDay) ||
((SettingsManager.ApiExcludeTimeStart.TimeOfDay > SettingsManager.ApiExcludeTimeEnd.TimeOfDay) &&
((DateTime.Now.TimeOfDay <= SettingsManager.ApiExcludeTimeStart.TimeOfDay &&
DateTime.Now.TimeOfDay <= SettingsManager.ApiExcludeTimeEnd.TimeOfDay) ||
(DateTime.Now.TimeOfDay >= SettingsManager.ApiExcludeTimeStart.TimeOfDay &&
DateTime.Now.TimeOfDay >= SettingsManager.ApiExcludeTimeEnd.TimeOfDay))) )
{
if ((DateTime.Now.TimeOfDay >= Settings.ApiExcludeTimeStart.TimeOfDay &&
DateTime.Now.TimeOfDay <= Settings.ApiExcludeTimeEnd.TimeOfDay) ||
((Settings.ApiExcludeTimeStart.TimeOfDay > Settings.ApiExcludeTimeEnd.TimeOfDay) &&
((DateTime.Now.TimeOfDay <= Settings.ApiExcludeTimeStart.TimeOfDay &&
DateTime.Now.TimeOfDay <= Settings.ApiExcludeTimeEnd.TimeOfDay) ||
(DateTime.Now.TimeOfDay >= Settings.ApiExcludeTimeStart.TimeOfDay &&
DateTime.Now.TimeOfDay >= Settings.ApiExcludeTimeEnd.TimeOfDay))))
{
responseText = "API exclude times enabled and within time range.";
context.Response.SendResponse(responseText);
return context;
}
responseText = "API exclude times enabled and within time range.";
LOG.Info($"Sending response: {responseText}");
context.Response.SendResponse(responseText);
return context;
}

Form1.ToggleCapture(command);
responseText = $"API command {command} completed successfully.";
}

if (command == "STATE")
{
responseText = $"{Form1._captureEnabled}";
}
_mainForm.ToggleCapture((MainForm.CaptureCommand) Enum.Parse(typeof(MainForm.CaptureCommand), command));
responseText = $"API command {command} completed successfully.";
}
context.Response.SendResponse(responseText);
return context;

if ( command == "STATE" )
{
responseText = $"{_mainForm.CaptureEnabled}";
}
}
else
{
LOG.Warn("API Command Empty / Invalid");
}
LOG.Info($"Sending response: {responseText}");
context.Response.SendResponse(responseText);
return context;
}

private string GetAclUrl(string hostname, string port)
{
return "http://" + hostname + ":" + port + "/";
}

private bool IsAclUrlReserved(string hostname, string port)
{
var aclUrl = GetAclUrl(hostname, port);
ProcessStartInfo processStartInfo = new ProcessStartInfo
{
FileName = "netsh.exe",
CreateNoWindow = true,
UseShellExecute = false,
Arguments = $"http show urlacl url={aclUrl}",
WindowStyle = ProcessWindowStyle.Hidden,
RedirectStandardOutput = true
};
LOG.Info($"Starting process: {processStartInfo.FileName} {processStartInfo.Arguments}");
var process = Process.Start(processStartInfo);
process.WaitForExit();
var output = process.StandardOutput.ReadToEnd();
/*
* Sample output:
*
* ACL URL Not Reserved:
* URL Reservations:
* -----------------
*
* ACL URL Reserved:
* URL Reservations:
* -----------------
*
* Reserved URL : http://+:9191/
* User: DOMAIN\user
* Listen: Yes
* Delegate: No
* SDDL: D:(A;;GX;;;S-1-5-21-566402754-1856570991-3730105997-1001)
*/
return output.Contains(aclUrl);
}

private void ReserveAclUrl(string hostname, string port)
{
var aclUrl = GetAclUrl(hostname, port);
var user = WindowsIdentity.GetCurrent().Name;
ProcessStartInfo processStartInfo = new ProcessStartInfo
{
FileName = "netsh.exe",
CreateNoWindow = true,
UseShellExecute = true,
Arguments = $"http add urlacl url={aclUrl} user={user}",
WindowStyle = ProcessWindowStyle.Hidden,
Verb = "runas",
};
LOG.Info($"Starting elevated process: {processStartInfo.FileName} {processStartInfo.Arguments}");
var process = Process.Start(processStartInfo);
process.WaitForExit();
}
}
}
}
Loading