Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

Commit

Permalink
v1.4: New Windows API
Browse files Browse the repository at this point in the history
This version introduces a new Windows API. You can see https://github.com/Rap-ID/Rap-ID/blob/9c72b470bbc0b21c2f68c9ddb410115a2e494a9d/doc/windows/Windows%20API%20Document.md for more details.

Draftsman: coderfox
Reviewer: coderfox
  • Loading branch information
xfoxfu committed Aug 9, 2015
2 parents bbec204 + a0be44a commit bbd112a
Show file tree
Hide file tree
Showing 16 changed files with 109 additions and 197 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Compiled Files
out
Rap-ID

## Assembly temp files
AssemblyInfo.old
Expand Down
19 changes: 3 additions & 16 deletions Auth/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,10 @@ static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
// callback& app
var callback = DecodeUrlString(args[0]);
var app = Crypt.Decrypt(Crypt.Decrypt(Crypt.Decrypt(args[1])));
var waitFrm = new Wait(callback, app);
// app
var app = Crypt.Decrypt(Crypt.Decrypt(Crypt.Decrypt(args[0])));
var waitFrm = new Wait(app);
Application.Run(waitFrm);
}

/*
* (C) 2015 @ogi from StackOverflow
* Original Post: http://stackoverflow.com/questions/1405048/how-do-i-decode-a-url-parameter-using-c
*/
private static string DecodeUrlString(string url)
{
string newUrl;
while ((newUrl = Uri.UnescapeDataString(url)) != url)
url = newUrl;
return newUrl;
}
}
}
6 changes: 3 additions & 3 deletions Auth/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[assembly: AssemblyTitle("Auth")]
[assembly: AssemblyDescription("auth ui provider for Rap-ID")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Cotr Community")]
[assembly: AssemblyCompany("Rap-ID Project")]
[assembly: AssemblyProduct("Rap-ID")]
[assembly: AssemblyCopyright("Copyright © 2015 coderfox")]
[assembly: AssemblyTrademark("Rap-ID")]
Expand All @@ -32,5 +32,5 @@
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0.13")]
[assembly: AssemblyFileVersion("1.2.0.13")]
[assembly: AssemblyVersion("1.3.1.3")]
[assembly: AssemblyFileVersion("1.3.1.3")]
21 changes: 10 additions & 11 deletions Auth/Wait.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ namespace RapID.Auth
{
public partial class Wait : Form
{
private string _callback;
private string _app;
public Wait(string callback, string app)
public Wait(string app)
{
InitializeComponent();
this._callback = callback;
this._app = app;
}

Expand Down Expand Up @@ -58,6 +56,7 @@ private async void okButton_Click(object sender, EventArgs e)
const string auth_prefix = "AUTH";
const string authok_prefix = "AUTHOK";
const string authfail_prefix = "AUTHFAIL";
const string c_cliResultPrefix = "#Rap-ID-Windows/CLI/1.0d/Auth/";

this.SetInfoText("正在读取配置文件...");

Expand Down Expand Up @@ -85,25 +84,25 @@ private async void okButton_Click(object sender, EventArgs e)
using (var tcpStreamReader = new StreamReader(tcpClient.GetStream()))
{
var message = Crypt.Decrypt(await tcpStreamReader.ReadLineAsync(), Crypt.GenerateKey(cryptionKey));
#if DEBUG
MessageBox.Show(message);
#endif
if (message.StartsWith(authok_prefix))
{
var token = message.Remove(message.IndexOf(authok_prefix), authok_prefix.Length);
#if DEBUG
MessageBox.Show(token);
#endif
this.SetInfoText("授权成功!");
System.Threading.Thread.Sleep(1000);
if (_callback != String.Empty)
{
System.Diagnostics.Process.Start(_callback + message.Replace(authok_prefix, String.Empty));
}
// output token
Console.WriteLine(c_cliResultPrefix + "result=ok;token=" + token);
}
else if (message.StartsWith(authfail_prefix))
{
this.SetInfoText("授权失败!");
System.Threading.Thread.Sleep(1000);
// output error
Console.WriteLine(c_cliResultPrefix + "result=fail;error=NotImpled");
}
}

}
}
Application.Exit();
Expand Down
6 changes: 3 additions & 3 deletions Configure/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[assembly: AssemblyTitle("Rap-ID Configure")]
[assembly: AssemblyDescription("configure program for Rap-ID")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Cotr Community")]
[assembly: AssemblyCompany("Rap-ID Project")]
[assembly: AssemblyProduct("Rap-ID")]
[assembly: AssemblyCopyright("Copyright © 2015 coderfox")]
[assembly: AssemblyTrademark("Rap-ID")]
Expand All @@ -32,5 +32,5 @@
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0.9")]
[assembly: AssemblyFileVersion("1.1.0.9")]
[assembly: AssemblyVersion("1.1.0.13")]
[assembly: AssemblyFileVersion("1.1.0.13")]
4 changes: 2 additions & 2 deletions CryptionDebugger/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.1.6")]
[assembly: AssemblyFileVersion("1.1.1.6")]
[assembly: AssemblyVersion("1.1.1.12")]
[assembly: AssemblyFileVersion("1.1.1.12")]
25 changes: 13 additions & 12 deletions Installer/Install.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,42 @@ private void Install_Load(object sender, EventArgs e)
this.dirBox.Text = AppDomain.CurrentDomain.BaseDirectory;
}

/// <summary>
/// 注册启动项到注册表
/// </summary>
public void RegURL(string name)
{
//注册的协议头,即在地址栏中的路径 如QQ的:tencent://xxxxx/xxx 我注册的是jun 在地址栏中输入:jun:// 就能打开本程序
var surekamKey = Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(name);
//以下这些参数都是固定的,不需要更改,直接复制过去
var shellKey = surekamKey.CreateSubKey("shell");
var openKey = shellKey.CreateSubKey("open");
var commandKey = openKey.CreateSubKey("command");
surekamKey.SetValue("URL Protocol", "");
//这里可执行文件取当前程序全路径,可根据需要修改
var exePath = this.dirBox.Text + "URLSchemeHandler.exe";
commandKey.SetValue("", "\"" + exePath + "\"" + " \"%1\"");
}

/// <summary>
/// 取消注册
/// </summary>
public void UnRegURL(string name)
public void UnReg(string name)
{
//直接删除节点
Microsoft.Win32.Registry.ClassesRoot.DeleteSubKeyTree(name);
}

public void RegFilePos(string name)
{
var surekamKey = Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(name);
var dirKey = surekamKey.CreateSubKey("dir");
var insPath = this.dirBox.Text;
dirKey.SetValue("", insPath);
var authPath = this.dirBox.Text + "auth.exe";
dirKey.SetValue("auth", authPath);
}

private void insButton_Click(object sender, EventArgs e)
{
RegURL("rapid");
RegFilePos("rapid");
System.Diagnostics.Process.Start(this.dirBox.Text + "conf.exe");
}

private void uninsButton_Click(object sender, EventArgs e)
{
UnRegURL("rapid");
UnReg("rapid");
}
}
}
6 changes: 3 additions & 3 deletions Installer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[assembly: AssemblyTitle("Rap-ID Installer")]
[assembly: AssemblyDescription("installer for Rap-ID")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Cotr Community")]
[assembly: AssemblyCompany("Rap-ID Project")]
[assembly: AssemblyProduct("Rap-ID")]
[assembly: AssemblyCopyright("Copyright © 2015 coderfox")]
[assembly: AssemblyTrademark("Rap-ID")]
Expand All @@ -32,5 +32,5 @@
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.15")]
[assembly: AssemblyFileVersion("1.0.0.15")]
[assembly: AssemblyVersion("1.1.0.9")]
[assembly: AssemblyFileVersion("1.1.0.9")]
26 changes: 26 additions & 0 deletions Jakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
desc('Gather the DEBUG compiled files.');
task('debug', function () {
jake.mkdirP('Rap-ID/debug');
jake.exec([
'cp -R Auth/bin/Debug/* Rap-ID/debug/',
'cp -R Configure/bin/Debug/* Rap-ID/debug/',
'cp -R Installer/bin/Debug/* Rap-ID/debug/',
'cp -R URLSchemeHandler/bin/Debug/* Rap-ID/debug/',
'cp -R Library/bin/Debug/* Rap-ID/debug/'
]);
});
desc('Gather the RELEASE compiled files.');
task('release', function () {
jake.mkdirP('Rap-ID/release');
jake.exec([
'cp -R Auth/bin/Release/* Rap-ID/release/',
'cp -R Configure/bin/Release/* Rap-ID/release/',
'cp -R Installer/bin/Release/* Rap-ID/release/',
'cp -R URLSchemeHandler/bin/Release/* Rap-ID/release/',
'cp -R Library/bin/Release/* Rap-ID/release/'
]);
});
desc('Clean up the directory.');
task('clean', function () {
jake.rmRf('Rap-ID');
});
6 changes: 1 addition & 5 deletions Library/Library.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,12 @@
</Compile>
<Compile Include="Objects\Device.cs" />
<Compile Include="Utils\Encoding.cs" />
<Compile Include="Utils\Error.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Utils\Error.cs" />
<Compile Include="Utils\INetwork.cs" />
<Compile Include="Utils\Log.cs" />
<Compile Include="Utils\Network.cs" />
<Compile Include="Utils\Crypt.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utils\TCPClient.cs" />
<Compile Include="Utils\TCPServer.cs" />
<Compile Include="Utils\UDPServer.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions Library/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[assembly: AssemblyTitle("Rap-ID Library")]
[assembly: AssemblyDescription("class library of Rap-ID")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Cotr Community")]
[assembly: AssemblyCompany("Rap-ID Project")]
[assembly: AssemblyProduct("Rap-ID")]
[assembly: AssemblyCopyright("Copyright © 2015 coderfox")]
[assembly: AssemblyTrademark("Rap-ID")]
Expand All @@ -32,5 +32,5 @@
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0.11")]
[assembly: AssemblyFileVersion("1.2.0.11")]
[assembly: AssemblyVersion("1.2.0.19")]
[assembly: AssemblyFileVersion("1.2.0.19")]
88 changes: 0 additions & 88 deletions Library/Utils/TCPClient.cs

This file was deleted.

Loading

0 comments on commit bbd112a

Please sign in to comment.