mirror of
https://github.com/rvtr/TwlToolsRED.git
synced 2025-10-31 06:41:18 -04:00
フィンガープリンタ:TWLのSRLの予約領域に固定バイト列を埋め込むプログラム。
git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlToolsRED@256 7061adef-622a-194b-ae81-725974e89856
This commit is contained in:
parent
5b1a108590
commit
ef5393defe
BIN
build/tools/MasterEditor/FingerPrinterTWL/FingerPrinterTWL.ncb
Normal file
BIN
build/tools/MasterEditor/FingerPrinterTWL/FingerPrinterTWL.ncb
Normal file
Binary file not shown.
@ -0,0 +1,20 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual Studio 2008
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FingerPrinterTWL", "FingerPrinterTWL\FingerPrinterTWL.vcproj", "{F41F8415-6AF1-46DF-B771-30B5AE234B89}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{F41F8415-6AF1-46DF-B771-30B5AE234B89}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{F41F8415-6AF1-46DF-B771-30B5AE234B89}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{F41F8415-6AF1-46DF-B771-30B5AE234B89}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{F41F8415-6AF1-46DF-B771-30B5AE234B89}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
BIN
build/tools/MasterEditor/FingerPrinterTWL/FingerPrinterTWL.suo
Normal file
BIN
build/tools/MasterEditor/FingerPrinterTWL/FingerPrinterTWL.suo
Normal file
Binary file not shown.
@ -0,0 +1,40 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
using namespace System;
|
||||
using namespace System::Reflection;
|
||||
using namespace System::Runtime::CompilerServices;
|
||||
using namespace System::Runtime::InteropServices;
|
||||
using namespace System::Security::Permissions;
|
||||
|
||||
//
|
||||
// アセンブリに関する一般情報は以下の属性セットをとおして制御されます。
|
||||
// アセンブリに関連付けられている情報を変更するには、
|
||||
// これらの属性値を変更してください。
|
||||
//
|
||||
[assembly:AssemblyTitleAttribute("FingerPrinterTWL")];
|
||||
[assembly:AssemblyDescriptionAttribute("")];
|
||||
[assembly:AssemblyConfigurationAttribute("")];
|
||||
[assembly:AssemblyCompanyAttribute("任天堂株式会社")];
|
||||
[assembly:AssemblyProductAttribute("FingerPrinterTWL")];
|
||||
[assembly:AssemblyCopyrightAttribute("Copyright (c) 任天堂株式会社 2009")];
|
||||
[assembly:AssemblyTrademarkAttribute("")];
|
||||
[assembly:AssemblyCultureAttribute("")];
|
||||
|
||||
//
|
||||
// アセンブリのバージョン情報は、以下の 4 つの値で構成されています:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// すべての値を指定するか、下のように '*' を使ってリビジョンおよびビルド番号を
|
||||
// 既定値にすることができます:
|
||||
|
||||
[assembly:AssemblyVersionAttribute("1.0.*")];
|
||||
|
||||
[assembly:ComVisible(false)];
|
||||
|
||||
[assembly:CLSCompliantAttribute(true)];
|
||||
|
||||
[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)];
|
||||
@ -0,0 +1,18 @@
|
||||
// FingerPrinterTWL.cpp : メイン プロジェクト ファイルです。
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "Form1.h"
|
||||
|
||||
using namespace FingerPrinterTWL;
|
||||
|
||||
[STAThreadAttribute]
|
||||
int main(array<System::String ^> ^args)
|
||||
{
|
||||
// コントロールが作成される前に、Windows XP ビジュアル効果を有効にします
|
||||
Application::EnableVisualStyles();
|
||||
Application::SetCompatibleTextRenderingDefault(false);
|
||||
|
||||
// メイン ウィンドウを作成して、実行します
|
||||
Application::Run(gcnew Form1());
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,292 @@
|
||||
<?xml version="1.0" encoding="shift_jis"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="FingerPrinterTWL"
|
||||
ProjectGUID="{F41F8415-6AF1-46DF-B771-30B5AE234B89}"
|
||||
RootNamespace="FingerPrinterTWL"
|
||||
Keyword="ManagedCProj"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
ManagedExtensions="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""C:\Documents and Settings\nishikawa_takeshi\My Documents\Visual Studio 2008\Projects\MasterEditorTWL";C:\twlsdk\build\tools\makerom.TWL;C:\twlsdk\include;"C:\Documents and Settings\nishikawa_takeshi\My Documents\Visual Studio 2008\Projects\MasterEditorTWL_Common\user""
|
||||
PreprocessorDefinitions="WIN32;_DEBUG"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="2"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="libacsign_X86.a libaes_X86.a libdigest_X86.a libflags_X86.a $(NOINHERIT)"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories=""C:\Documents and Settings\nishikawa_takeshi\My Documents\Visual Studio 2008\Projects\MasterEditorTWL_Common\flags\lib\X86";C:\twlsdk\build\tools\makerom.TWL\digest\lib\X86;C:\twlsdk\build\tools\makerom.TWL\aes\lib\X86;C:\twlsdk\build\tools\makerom.TWL\acsign\lib\X86"
|
||||
GenerateDebugInformation="true"
|
||||
AssemblyDebug="1"
|
||||
SubSystem="1"
|
||||
EntryPointSymbol="main"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
ManagedExtensions="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""C:\Documents and Settings\nishikawa_takeshi\My Documents\Visual Studio 2008\Projects\MasterEditorTWL";C:\twlsdk\build\tools\makerom.TWL;C:\twlsdk\include;"C:\Documents and Settings\nishikawa_takeshi\My Documents\Visual Studio 2008\Projects\MasterEditorTWL_Common\user""
|
||||
PreprocessorDefinitions="WIN32;NDEBUG"
|
||||
RuntimeLibrary="2"
|
||||
UsePrecompiledHeader="2"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="libacsign_X86.a libaes_X86.a libdigest_X86.a libflags_X86.a $(NOINHERIT)"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories=""C:\Documents and Settings\nishikawa_takeshi\My Documents\Visual Studio 2008\Projects\MasterEditorTWL_Common\flags\lib\X86";C:\twlsdk\build\tools\makerom.TWL\digest\lib\X86;C:\twlsdk\build\tools\makerom.TWL\aes\lib\X86;C:\twlsdk\build\tools\makerom.TWL\acsign\lib\X86"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
EntryPointSymbol="main"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
<AssemblyReference
|
||||
RelativePath="System.dll"
|
||||
AssemblyName="System, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
|
||||
MinFrameworkVersion="131072"
|
||||
/>
|
||||
<AssemblyReference
|
||||
RelativePath="System.Data.dll"
|
||||
AssemblyName="System.Data, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86"
|
||||
MinFrameworkVersion="131072"
|
||||
/>
|
||||
<AssemblyReference
|
||||
RelativePath="System.Drawing.dll"
|
||||
AssemblyName="System.Drawing, Version=2.0.0.0, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
|
||||
MinFrameworkVersion="131072"
|
||||
/>
|
||||
<AssemblyReference
|
||||
RelativePath="System.Windows.Forms.dll"
|
||||
AssemblyName="System.Windows.Forms, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
|
||||
MinFrameworkVersion="131072"
|
||||
/>
|
||||
<AssemblyReference
|
||||
RelativePath="System.XML.dll"
|
||||
AssemblyName="System.Xml, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
|
||||
MinFrameworkVersion="131072"
|
||||
/>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="ソース ファイル"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\AssemblyInfo.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fingerprinter_util.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\FingerPrinterTWL.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Form1.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\MasterEditorTWL\MasterEditorTWL\keys.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\stdafx.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="ヘッダー ファイル"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\fingerprint_util.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Form1.h"
|
||||
FileType="3"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\Form1.resX"
|
||||
SubType="Designer"
|
||||
>
|
||||
</File>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\resource.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\stdafx.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="リソース ファイル"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\app.ico"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\app.rc"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\ReadMe.txt"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="shift_jis"?>
|
||||
<VisualStudioUserFile
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
ShowAllFiles="false"
|
||||
>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<DebugSettings
|
||||
Command="$(TargetPath)"
|
||||
WorkingDirectory=""
|
||||
CommandArguments=""
|
||||
Attach="false"
|
||||
DebuggerType="3"
|
||||
Remote="1"
|
||||
RemoteMachine="PC2355"
|
||||
RemoteCommand=""
|
||||
HttpUrl=""
|
||||
PDBPath=""
|
||||
SQLDebugging=""
|
||||
Environment=""
|
||||
EnvironmentMerge="true"
|
||||
DebuggerFlavor=""
|
||||
MPIRunCommand=""
|
||||
MPIRunArguments=""
|
||||
MPIRunWorkingDirectory=""
|
||||
ApplicationCommand=""
|
||||
ApplicationArguments=""
|
||||
ShimCommand=""
|
||||
MPIAcceptMode=""
|
||||
MPIAcceptFilter=""
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<DebugSettings
|
||||
Command="$(TargetPath)"
|
||||
WorkingDirectory=""
|
||||
CommandArguments=""
|
||||
Attach="false"
|
||||
DebuggerType="3"
|
||||
Remote="1"
|
||||
RemoteMachine="PC2355"
|
||||
RemoteCommand=""
|
||||
HttpUrl=""
|
||||
PDBPath=""
|
||||
SQLDebugging=""
|
||||
Environment=""
|
||||
EnvironmentMerge="true"
|
||||
DebuggerFlavor=""
|
||||
MPIRunCommand=""
|
||||
MPIRunArguments=""
|
||||
MPIRunWorkingDirectory=""
|
||||
ApplicationCommand=""
|
||||
ApplicationArguments=""
|
||||
ShimCommand=""
|
||||
MPIAcceptMode=""
|
||||
MPIAcceptFilter=""
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
</VisualStudioUserFile>
|
||||
@ -0,0 +1,152 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "Form1.h"
|
||||
#include <twl/types.h>
|
||||
#include <twl/os/common/format_rom.h>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include "fingerprint_util.h"
|
||||
|
||||
using namespace FingerPrinterTWL;
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// 開始 & 終了処理
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
void Form1::construct()
|
||||
{
|
||||
this->rh = NULL;
|
||||
this->rh = new ROM_Header;
|
||||
memset( this->rh, 0, sizeof(ROM_Header) );
|
||||
this->prevDir = nullptr;
|
||||
|
||||
System::String ^example = "Input Example\r\n\r\n"
|
||||
+ "(1)String of ASCII Charactors\r\n"
|
||||
+ " *THIS IS FINGERPRINT\r\n\r\n"
|
||||
+ "(2)Hexadecimal Numbers\r\n"
|
||||
+ " *5A6B78014A235A\r\n"
|
||||
+ " *5a6b78014a235a\r\n"
|
||||
+ " *5A 6B 78 01 4A 23 5A\r\n"
|
||||
+ " (2 charactor per 1 number)";
|
||||
this->tboxExample->Text = example;
|
||||
}
|
||||
|
||||
void Form1::destruct()
|
||||
{
|
||||
if( this->rh )
|
||||
{
|
||||
delete this->rh;
|
||||
}
|
||||
this->rh = NULL;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// フィンガープリント
|
||||
// ------------------------------------------------------------------
|
||||
void Form1::fingerprintRomHeader()
|
||||
{
|
||||
System::String ^fingerprint = this->tboxFP->Text;
|
||||
cli::array<System::Byte> ^bytes;
|
||||
|
||||
// ROMヘッダにフィンガープリントを入れる
|
||||
if( this->rHex->Checked )
|
||||
{
|
||||
bytes = TransHexStringToBytes( fingerprint, 32 );
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes = TransStringToBytes( fingerprint, 32 );
|
||||
}
|
||||
pin_ptr<unsigned char> buf = &bytes[0]; // 解放の必要なし
|
||||
memcpy( this->rh->s.reserved_C, buf, 32 );
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// ファイル処理を共通化させる
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
void Form1::commonOpenRom( System::String ^srcpath )
|
||||
{
|
||||
memset( this->rh, 0, sizeof(ROM_Header) );
|
||||
ReadRomHeader( srcpath, this->rh );
|
||||
this->tboxFile->Text = srcpath;
|
||||
this->tboxFile->SelectionStart = srcpath->Length; // 入りきらないときに右端を表示する
|
||||
}
|
||||
|
||||
void Form1::commonSaveRom( System::String ^dstpath )
|
||||
{
|
||||
System::String ^srcpath = this->tboxFile->Text;
|
||||
if( !srcpath )
|
||||
{
|
||||
throw gcnew Exception("The input ROM file has not read yet.");
|
||||
}
|
||||
|
||||
// ファイルをコピーしてROMヘッダを上書き
|
||||
if( !srcpath->Equals( dstpath ) )
|
||||
{
|
||||
CopyFile( srcpath, dstpath );
|
||||
}
|
||||
this->fingerprintRomHeader();
|
||||
WriteRomHeader( dstpath, this->rh );
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// ボタンが押されたときの処理 (catch文必須)
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
void Form1::procOpenRomButton()
|
||||
{
|
||||
try
|
||||
{
|
||||
// System::String ^rompath = OpenFileUsingDialog( this->prevDir, "rom format (*.srl;*.tad)|*.srl;*.tad|All files (*.*)|*.*" );
|
||||
System::String ^rompath = OpenFileUsingDialog( this->prevDir, "rom format (*.srl)|*.srl|All files (*.*)|*.*" );
|
||||
if( !rompath )
|
||||
{
|
||||
return;
|
||||
}
|
||||
this->commonOpenRom( rompath );
|
||||
this->prevDir = System::IO::Path::GetDirectoryName( rompath );
|
||||
}
|
||||
catch( System::Exception ^ex )
|
||||
{
|
||||
this->errMsg( ex->Message );
|
||||
}
|
||||
}
|
||||
|
||||
void Form1::procSaveRomButton()
|
||||
{
|
||||
try
|
||||
{
|
||||
System::String ^rompath = SaveFileUsingDialog( this->prevDir, "rom format (*.srl)|*.srl|All files (*.*)|*.*", ".srl" );
|
||||
if( !rompath )
|
||||
{
|
||||
return;
|
||||
}
|
||||
this->commonSaveRom( rompath );
|
||||
this->prevDir = System::IO::Path::GetDirectoryName( rompath );
|
||||
this->sucMsg( "Succeed to fingerprint.\n\n{0}", rompath );
|
||||
}
|
||||
catch( System::Exception ^ex )
|
||||
{
|
||||
this->errMsg( ex->Message );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// エラーメッセージ
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
void Form1::sucMsg( System::String ^fmt, ... cli::array<System::String^> ^args )
|
||||
{
|
||||
System::String ^msg = System::String::Format( fmt, args ); // 書式をStringに展開
|
||||
MessageBox::Show( msg, "SUCCESS", MessageBoxButtons::OK, MessageBoxIcon::Information );
|
||||
}
|
||||
|
||||
void Form1::errMsg( System::String ^fmt, ... cli::array<System::String^> ^args )
|
||||
{
|
||||
System::String ^msg = System::String::Format( fmt, args ); // 書式をStringに展開
|
||||
MessageBox::Show( msg, "Error", MessageBoxButtons::OK, MessageBoxIcon::Error );
|
||||
}
|
||||
@ -0,0 +1,310 @@
|
||||
#pragma once
|
||||
|
||||
#include <twl/types.h>
|
||||
#include <twl/os/common/format_rom.h>
|
||||
|
||||
namespace FingerPrinterTWL {
|
||||
|
||||
using namespace System;
|
||||
using namespace System::ComponentModel;
|
||||
using namespace System::Collections;
|
||||
using namespace System::Windows::Forms;
|
||||
using namespace System::Data;
|
||||
using namespace System::Drawing;
|
||||
|
||||
/// <summary>
|
||||
/// Form1 の概要
|
||||
///
|
||||
/// 警告: このクラスの名前を変更する場合、このクラスが依存するすべての .resx ファイルに関連付けられた
|
||||
/// マネージ リソース コンパイラ ツールに対して 'Resource File Name' プロパティを
|
||||
/// 変更する必要があります。この変更を行わないと、
|
||||
/// デザイナと、このフォームに関連付けられたローカライズ済みリソースとが、
|
||||
/// 正しく相互に利用できなくなります。
|
||||
/// </summary>
|
||||
public ref class Form1 : public System::Windows::Forms::Form
|
||||
{
|
||||
public:
|
||||
Form1(void)
|
||||
{
|
||||
InitializeComponent();
|
||||
//
|
||||
//TODO: ここにコンストラクタ コードを追加します
|
||||
//
|
||||
this->construct();
|
||||
}
|
||||
|
||||
protected:
|
||||
/// <summary>
|
||||
/// 使用中のリソースをすべてクリーンアップします。
|
||||
/// </summary>
|
||||
~Form1()
|
||||
{
|
||||
this->!Form1();
|
||||
}
|
||||
!Form1()
|
||||
{
|
||||
this->destruct();
|
||||
if (components)
|
||||
{
|
||||
delete components;
|
||||
}
|
||||
}
|
||||
private: System::Windows::Forms::TextBox^ tboxFile;
|
||||
protected:
|
||||
|
||||
protected:
|
||||
private: System::Windows::Forms::Label^ labFile;
|
||||
private: System::Windows::Forms::Button^ butFile;
|
||||
private: System::Windows::Forms::GroupBox^ gboxFP;
|
||||
private: System::Windows::Forms::TextBox^ tboxExample;
|
||||
|
||||
private: System::Windows::Forms::TextBox^ tboxFP;
|
||||
private: System::Windows::Forms::GroupBox^ gboxType;
|
||||
private: System::Windows::Forms::RadioButton^ rHex;
|
||||
|
||||
private: System::Windows::Forms::RadioButton^ rString;
|
||||
private: System::Windows::Forms::Label^ labShorter;
|
||||
private: System::Windows::Forms::Button^ butFP;
|
||||
|
||||
|
||||
|
||||
private: System::Windows::Forms::Label^ labFP;
|
||||
|
||||
|
||||
private:
|
||||
/// <summary>
|
||||
/// 必要なデザイナ変数です。
|
||||
/// </summary>
|
||||
System::ComponentModel::Container ^components;
|
||||
|
||||
#pragma region Windows Form Designer generated code
|
||||
/// <summary>
|
||||
/// デザイナ サポートに必要なメソッドです。このメソッドの内容を
|
||||
/// コード エディタで変更しないでください。
|
||||
/// </summary>
|
||||
void InitializeComponent(void)
|
||||
{
|
||||
this->tboxFile = (gcnew System::Windows::Forms::TextBox());
|
||||
this->labFile = (gcnew System::Windows::Forms::Label());
|
||||
this->butFile = (gcnew System::Windows::Forms::Button());
|
||||
this->gboxFP = (gcnew System::Windows::Forms::GroupBox());
|
||||
this->labFP = (gcnew System::Windows::Forms::Label());
|
||||
this->labShorter = (gcnew System::Windows::Forms::Label());
|
||||
this->butFP = (gcnew System::Windows::Forms::Button());
|
||||
this->tboxExample = (gcnew System::Windows::Forms::TextBox());
|
||||
this->tboxFP = (gcnew System::Windows::Forms::TextBox());
|
||||
this->gboxType = (gcnew System::Windows::Forms::GroupBox());
|
||||
this->rHex = (gcnew System::Windows::Forms::RadioButton());
|
||||
this->rString = (gcnew System::Windows::Forms::RadioButton());
|
||||
this->gboxFP->SuspendLayout();
|
||||
this->gboxType->SuspendLayout();
|
||||
this->SuspendLayout();
|
||||
//
|
||||
// tboxFile
|
||||
//
|
||||
this->tboxFile->Location = System::Drawing::Point(85, 31);
|
||||
this->tboxFile->Name = L"tboxFile";
|
||||
this->tboxFile->ReadOnly = true;
|
||||
this->tboxFile->Size = System::Drawing::Size(313, 19);
|
||||
this->tboxFile->TabIndex = 0;
|
||||
//
|
||||
// labFile
|
||||
//
|
||||
this->labFile->AutoSize = true;
|
||||
this->labFile->Location = System::Drawing::Point(26, 34);
|
||||
this->labFile->Name = L"labFile";
|
||||
this->labFile->Size = System::Drawing::Size(53, 12);
|
||||
this->labFile->TabIndex = 1;
|
||||
this->labFile->Text = L"ROM File";
|
||||
//
|
||||
// butFile
|
||||
//
|
||||
this->butFile->Location = System::Drawing::Point(404, 29);
|
||||
this->butFile->Name = L"butFile";
|
||||
this->butFile->Size = System::Drawing::Size(82, 23);
|
||||
this->butFile->TabIndex = 2;
|
||||
this->butFile->Text = L"Open File";
|
||||
this->butFile->UseVisualStyleBackColor = true;
|
||||
this->butFile->Click += gcnew System::EventHandler(this, &Form1::butFile_Click);
|
||||
//
|
||||
// gboxFP
|
||||
//
|
||||
this->gboxFP->Controls->Add(this->labFP);
|
||||
this->gboxFP->Controls->Add(this->labShorter);
|
||||
this->gboxFP->Controls->Add(this->butFP);
|
||||
this->gboxFP->Controls->Add(this->tboxExample);
|
||||
this->gboxFP->Controls->Add(this->tboxFP);
|
||||
this->gboxFP->Controls->Add(this->gboxType);
|
||||
this->gboxFP->Location = System::Drawing::Point(28, 71);
|
||||
this->gboxFP->Name = L"gboxFP";
|
||||
this->gboxFP->Size = System::Drawing::Size(458, 261);
|
||||
this->gboxFP->TabIndex = 3;
|
||||
this->gboxFP->TabStop = false;
|
||||
//
|
||||
// labFP
|
||||
//
|
||||
this->labFP->AutoSize = true;
|
||||
this->labFP->Location = System::Drawing::Point(20, 150);
|
||||
this->labFP->Name = L"labFP";
|
||||
this->labFP->Size = System::Drawing::Size(60, 12);
|
||||
this->labFP->TabIndex = 5;
|
||||
this->labFP->Text = L"Fingerprint";
|
||||
//
|
||||
// labShorter
|
||||
//
|
||||
this->labShorter->AutoSize = true;
|
||||
this->labShorter->Location = System::Drawing::Point(320, 204);
|
||||
this->labShorter->Name = L"labShorter";
|
||||
this->labShorter->Size = System::Drawing::Size(124, 12);
|
||||
this->labShorter->TabIndex = 4;
|
||||
this->labShorter->Text = L"(Shorter than 32 bytes)";
|
||||
//
|
||||
// butFP
|
||||
//
|
||||
this->butFP->Location = System::Drawing::Point(151, 225);
|
||||
this->butFP->Name = L"butFP";
|
||||
this->butFP->Size = System::Drawing::Size(150, 23);
|
||||
this->butFP->TabIndex = 3;
|
||||
this->butFP->Text = L"Register Fingerprint";
|
||||
this->butFP->UseVisualStyleBackColor = true;
|
||||
this->butFP->Click += gcnew System::EventHandler(this, &Form1::butFP_Click);
|
||||
//
|
||||
// tboxExample
|
||||
//
|
||||
this->tboxExample->BackColor = System::Drawing::SystemColors::Info;
|
||||
this->tboxExample->Location = System::Drawing::Point(232, 18);
|
||||
this->tboxExample->Multiline = true;
|
||||
this->tboxExample->Name = L"tboxExample";
|
||||
this->tboxExample->ReadOnly = true;
|
||||
this->tboxExample->Size = System::Drawing::Size(212, 122);
|
||||
this->tboxExample->TabIndex = 2;
|
||||
//
|
||||
// tboxFP
|
||||
//
|
||||
this->tboxFP->Location = System::Drawing::Point(22, 165);
|
||||
this->tboxFP->Multiline = true;
|
||||
this->tboxFP->Name = L"tboxFP";
|
||||
this->tboxFP->Size = System::Drawing::Size(422, 36);
|
||||
this->tboxFP->TabIndex = 1;
|
||||
//
|
||||
// gboxType
|
||||
//
|
||||
this->gboxType->Controls->Add(this->rHex);
|
||||
this->gboxType->Controls->Add(this->rString);
|
||||
this->gboxType->Location = System::Drawing::Point(22, 18);
|
||||
this->gboxType->Name = L"gboxType";
|
||||
this->gboxType->Size = System::Drawing::Size(204, 113);
|
||||
this->gboxType->TabIndex = 0;
|
||||
this->gboxType->TabStop = false;
|
||||
this->gboxType->Text = L"Input Type";
|
||||
//
|
||||
// rHex
|
||||
//
|
||||
this->rHex->AutoSize = true;
|
||||
this->rHex->Location = System::Drawing::Point(18, 68);
|
||||
this->rHex->Name = L"rHex";
|
||||
this->rHex->Size = System::Drawing::Size(137, 16);
|
||||
this->rHex->TabIndex = 1;
|
||||
this->rHex->TabStop = true;
|
||||
this->rHex->Text = L"Hexadecimal Numbers";
|
||||
this->rHex->UseVisualStyleBackColor = true;
|
||||
//
|
||||
// rString
|
||||
//
|
||||
this->rString->AutoSize = true;
|
||||
this->rString->Checked = true;
|
||||
this->rString->Location = System::Drawing::Point(18, 37);
|
||||
this->rString->Name = L"rString";
|
||||
this->rString->Size = System::Drawing::Size(160, 16);
|
||||
this->rString->TabIndex = 0;
|
||||
this->rString->TabStop = true;
|
||||
this->rString->Text = L"String of ASCII Charactors";
|
||||
this->rString->UseVisualStyleBackColor = true;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this->AllowDrop = true;
|
||||
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::None;
|
||||
this->ClientSize = System::Drawing::Size(503, 352);
|
||||
this->Controls->Add(this->gboxFP);
|
||||
this->Controls->Add(this->butFile);
|
||||
this->Controls->Add(this->labFile);
|
||||
this->Controls->Add(this->tboxFile);
|
||||
this->Name = L"Form1";
|
||||
this->Text = L"TWL Fingerprinter";
|
||||
this->DragDrop += gcnew System::Windows::Forms::DragEventHandler(this, &Form1::Form1_DragDrop);
|
||||
this->DragEnter += gcnew System::Windows::Forms::DragEventHandler(this, &Form1::Form1_DragEnter);
|
||||
this->gboxFP->ResumeLayout(false);
|
||||
this->gboxFP->PerformLayout();
|
||||
this->gboxType->ResumeLayout(false);
|
||||
this->gboxType->PerformLayout();
|
||||
this->ResumeLayout(false);
|
||||
this->PerformLayout();
|
||||
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
// ================================================================================
|
||||
// internal functions
|
||||
// ================================================================================
|
||||
private:
|
||||
ROM_Header *rh;
|
||||
System::String ^prevDir; // 前に選択したディレクトリ
|
||||
|
||||
private:
|
||||
void construct();
|
||||
void destruct();
|
||||
|
||||
// フィンガープリント
|
||||
private:
|
||||
void fingerprintRomHeader();
|
||||
|
||||
// ファイル処理を共通化させる
|
||||
private:
|
||||
void commonOpenRom( System::String ^srcpath );
|
||||
void commonSaveRom( System::String ^dstpath );
|
||||
|
||||
// ボタンが押されたときの処理(例外catchを入れること)
|
||||
private:
|
||||
void procOpenRomButton();
|
||||
void procSaveRomButton();
|
||||
|
||||
// ダイアログ
|
||||
private:
|
||||
void sucMsg( System::String ^fmt, ... cli::array<System::String^> ^args );
|
||||
void errMsg( System::String ^fmt, ... cli::array<System::String^> ^args );
|
||||
|
||||
|
||||
// ================================================================================
|
||||
// GUI処理
|
||||
// ================================================================================
|
||||
// ボタン
|
||||
private:
|
||||
System::Void butFile_Click(System::Object^ sender, System::EventArgs^ e)
|
||||
{
|
||||
this->procOpenRomButton();
|
||||
}
|
||||
private:
|
||||
System::Void butFP_Click(System::Object^ sender, System::EventArgs^ e)
|
||||
{
|
||||
this->procSaveRomButton();
|
||||
}
|
||||
// ドラッグアンドドロップ
|
||||
private:
|
||||
System::Void Form1_DragEnter(System::Object^ sender, System::Windows::Forms::DragEventArgs^ e)
|
||||
{
|
||||
if( e->Data->GetDataPresent( DataFormats::FileDrop ) )
|
||||
{
|
||||
e->Effect = DragDropEffects::All;
|
||||
}
|
||||
}
|
||||
private:
|
||||
System::Void Form1_DragDrop(System::Object^ sender, System::Windows::Forms::DragEventArgs^ e)
|
||||
{
|
||||
array<String^> ^files = dynamic_cast< array<String^> ^>(e->Data->GetData( DataFormats::FileDrop ) );
|
||||
String ^path = files[0];
|
||||
this->commonOpenRom( path );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@ -0,0 +1,34 @@
|
||||
===============================================================================
|
||||
アプリケーション : FingerPrinterTWL プロジェクトの概要
|
||||
===============================================================================
|
||||
|
||||
この FingerPrinterTWL アプリケーションは、AppWizard によって作成されました。
|
||||
|
||||
このファイルには、FingerPrinterTWL アプリケーションを構成する各ファイルの
|
||||
内容の概略が記述されています。
|
||||
|
||||
FingerPrinterTWL.vcproj
|
||||
これは、アプリケーション ウィザードで生成される VC++ プロジェクトのメインの
|
||||
プロジェクト ファイルです。
|
||||
ファイルを生成した Visual C++ のバージョン情報と、アプリケーション ウィザー
|
||||
ドで選択したプラットフォーム、構成、およびプロジェクトの機能に関する情報が
|
||||
記述されています。
|
||||
|
||||
FingerPrinterTWL.cpp
|
||||
これは、メインのアプリケーション ソース ファイルです。
|
||||
フォームを表示するコードが含まれています。
|
||||
|
||||
Form1.h
|
||||
ユーザーのフォーム クラスの実装と、InitializeComponent() 関数が含まれています。
|
||||
|
||||
AssemblyInfo.cpp
|
||||
アセンブリ メタデータを変更するためのカスタム属性が含まれています。
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
その他の標準ファイル :
|
||||
|
||||
StdAfx.h, StdAfx.cpp
|
||||
これらのファイルは、コンパイル済みヘッダー (PCH) ファイル FingerPrinterTWL.pch
|
||||
とプリコンパイル済み型ファイル StdAfx.obj をビルドするために使用します。
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@ -0,0 +1,63 @@
|
||||
// Microsoft Visual C++ で生成されたリソース スクリプトです。
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// 英語 (米国) リソース
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// アイコン
|
||||
//
|
||||
|
||||
// 最初に配置されたアイコン、または ID 値が最も低いアイコンが、アプリケーション アイコンになります。
|
||||
|
||||
LANGUAGE 17, 1
|
||||
#pragma code_page(932)
|
||||
1 ICON "app.ico"
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
"\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE 3 リソースから生成されました。
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // APSTUDIO_INVOKED でない場合
|
||||
|
||||
@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
|
||||
#include <twl/types.h>
|
||||
#include <twl/os/common/format_rom.h>
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// ファイル処理
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// ファイルコピー
|
||||
void CopyFile( System::String ^srcpath, System::String ^dstpath );
|
||||
|
||||
// ROMヘッダのリード
|
||||
void ReadRomHeader( System::String ^srlpath, ROM_Header *dstrh );
|
||||
|
||||
// ROMヘッダのライト
|
||||
void WriteRomHeader( System::String ^srlpath, ROM_Header *srcrh );
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// 署名
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// ROMヘッダに署名をつける
|
||||
void SignRomHeader( ROM_Header *rh );
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// 変換
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// 文字列をバイト配列に変換
|
||||
cli::array<System::Byte>^ TransStringToBytes( System::String ^src, const int len );
|
||||
|
||||
// 16進文字列をバイト配列に変換
|
||||
cli::array<System::Byte>^ TransHexStringToBytes( System::String ^src, const int len );
|
||||
|
||||
// バイト配列を16進文字列に変換
|
||||
System::String^ TransBytesToString( cli::array<System::Byte> ^bytes );
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// GUI
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// ファイルをダイアログで取得
|
||||
// @arg [in] デフォルトのディレクトリ
|
||||
// @arg [in] 拡張子フィルタ
|
||||
// @ret 取得したファイル名 エラーのとき nullptr
|
||||
System::String^ OpenFileUsingDialog( System::String ^defdir, System::String ^filter );
|
||||
|
||||
// セーブするファイルをダイアログで取得
|
||||
// @arg [in] デフォルトのディレクトリ
|
||||
// @arg [in] 拡張子フィルタ
|
||||
// @arg [in] ファイルの拡張子が不正なときに追加するときの正しい拡張子
|
||||
// @ret 取得したファイル名 エラーのとき nullptr
|
||||
System::String^ SaveFileUsingDialog( System::String ^defdir, System::String ^filter, System::String ^extension );
|
||||
@ -0,0 +1,361 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include <apptype.h>
|
||||
#include <twl/types.h>
|
||||
#include <twl/os/common/format_rom.h>
|
||||
#include <acsign/include/acsign.h>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <MasterEditorTWL/keys.h>
|
||||
|
||||
using namespace MasterEditorTWL;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// ファイル処理
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// ファイルコピー
|
||||
#define COPY_FILE_BUFSIZE (10*1024*1024)
|
||||
void CopyFile( System::String ^srcpath, System::String ^dstpath )
|
||||
{
|
||||
System::IntPtr srcptr = System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi( srcpath );
|
||||
System::IntPtr dstptr = System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi( dstpath );
|
||||
const char *pchSrcFile = (const char*)srcptr.ToPointer();
|
||||
const char *pchDstFile = (const char*)dstptr.ToPointer();
|
||||
FILE *ifp = NULL;
|
||||
FILE *ofp = NULL;
|
||||
System::Exception ^ex = nullptr;
|
||||
|
||||
try
|
||||
{
|
||||
if( fopen_s( &ifp, pchSrcFile, "rb" ) != NULL )
|
||||
{
|
||||
ex = gcnew System::Exception( "Fail to open file:" + srcpath );
|
||||
throw ex;
|
||||
}
|
||||
if( fopen_s( &ofp, pchDstFile, "wb" ) != NULL ) // 同名ファイルを削除して新規にライト・バイナリ
|
||||
{
|
||||
ex = gcnew System::Exception( "Fail to open file:" + dstpath );
|
||||
throw ex;
|
||||
}
|
||||
|
||||
// 入力ファイルのサイズ取得
|
||||
fseek( ifp, 0, SEEK_END );
|
||||
System::Int32 size = ftell(ifp);
|
||||
|
||||
cli::array<System::Byte> ^mbuf = gcnew cli::array<System::Byte>(COPY_FILE_BUFSIZE); // 解放の必要なし
|
||||
pin_ptr<unsigned char> buf = &mbuf[0];
|
||||
fseek( ifp, 0, SEEK_SET );
|
||||
fseek( ofp, 0, SEEK_SET );
|
||||
while( size > 0 )
|
||||
{
|
||||
System::Int32 datasize = (COPY_FILE_BUFSIZE < size)?COPY_FILE_BUFSIZE:size;
|
||||
|
||||
if( datasize != fread(buf, 1, datasize, ifp) )
|
||||
{
|
||||
ex = gcnew System::Exception( "Fail to read data from " + srcpath );
|
||||
throw ex;
|
||||
}
|
||||
if( datasize != fwrite(buf, 1, datasize, ofp) )
|
||||
{
|
||||
ex = gcnew System::Exception( "Fail to write data to " + dstpath );
|
||||
throw ex;
|
||||
}
|
||||
size -= datasize;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
System::Runtime::InteropServices::Marshal::FreeHGlobal( srcptr );
|
||||
System::Runtime::InteropServices::Marshal::FreeHGlobal( dstptr );
|
||||
if( ifp ) fclose(ifp);
|
||||
if( ofp ) fclose(ofp);
|
||||
if( ex )
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ROMヘッダのリード
|
||||
void ReadRomHeader( System::String ^srlpath, ROM_Header *dstrh )
|
||||
{
|
||||
System::IntPtr ptr = System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi( srlpath );
|
||||
const char *pchFile = (const char*)ptr.ToPointer();
|
||||
FILE *fp = NULL;
|
||||
System::Exception ^ex = nullptr;
|
||||
|
||||
try
|
||||
{
|
||||
if( fopen_s( &fp, pchFile, "rb" ) != NULL )
|
||||
{
|
||||
ex = gcnew System::Exception( "Fail to open file:" + srlpath );
|
||||
throw ex;
|
||||
}
|
||||
fseek( fp, 0, SEEK_SET );
|
||||
if( fread( (void*)dstrh, 1, sizeof(ROM_Header), fp ) != sizeof(ROM_Header) )
|
||||
{
|
||||
ex = gcnew System::Exception( "Fail to read data from " + srlpath );
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
System::Runtime::InteropServices::Marshal::FreeHGlobal( ptr );
|
||||
if( fp ) fclose(fp);
|
||||
if( ex )
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ROMヘッダのライト
|
||||
void WriteRomHeader( System::String ^srlpath, ROM_Header *srcrh )
|
||||
{
|
||||
System::IntPtr ptr = System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi( srlpath );
|
||||
const char *pchFile = (const char*)ptr.ToPointer();
|
||||
FILE *fp = NULL;
|
||||
System::Exception ^ex = nullptr;
|
||||
|
||||
// ファイルにROMヘッダをライト
|
||||
try
|
||||
{
|
||||
if( fopen_s( &fp, pchFile, "r+b" ) != NULL ) // 上書き・バイナリ
|
||||
{
|
||||
ex = gcnew System::Exception( "Fail to open file:" + srlpath );
|
||||
throw ex;
|
||||
}
|
||||
(void)fseek( fp, 0, SEEK_SET );
|
||||
|
||||
if( fwrite( (const void*)srcrh, 1, sizeof(ROM_Header), fp ) != sizeof(ROM_Header) )
|
||||
{
|
||||
ex = gcnew System::Exception( "Fail to write data to " + srlpath );
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
System::Runtime::InteropServices::Marshal::FreeHGlobal( ptr );
|
||||
if( fp ) fclose( fp );
|
||||
if( ex )
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// 署名
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// ROMヘッダに署名をつける
|
||||
void SignRomHeader( ROM_Header *rh )
|
||||
{
|
||||
SignatureData signSrc; // 署名のもととなるダイジェスト値
|
||||
u8 signDst[ RSA_KEY_LENGTH ]; // 署名の格納先Tmpバッファ
|
||||
u8 decryptBlock[ RSA_KEY_LENGTH ]; // 署名を解除後ブロックバッファ
|
||||
BOOL result = false;
|
||||
int pos;
|
||||
u8 *privateKey = (u8*)g_devPrivKey_DER;
|
||||
u8 *publicKey = (u8*)g_devPubKey_DER;
|
||||
|
||||
// ROMヘッダのダイジェストを算出(先頭から証明書領域の直前までが対象)
|
||||
ACSign_DigestUnit(
|
||||
signSrc.digest,
|
||||
rh,
|
||||
(u32)&(rh->certificate) - (u32)rh // this->pRomHeader はマネージヒープ上にあるので実アドレスを取得できない
|
||||
);
|
||||
|
||||
// 鍵を選ぶ
|
||||
#ifdef METWL_VER_APPTYPE_LAUNCHER
|
||||
if( this->IsAppLauncher )
|
||||
{
|
||||
privateKey = (u8*)g_devPrivKey_DER_launcher;
|
||||
publicKey = (u8*)g_devPubKey_DER_launcher;
|
||||
}
|
||||
else
|
||||
#endif //METWL_VER_APPTYPE_LAUNCHER
|
||||
#ifdef METWL_VER_APPTYPE_SECURE
|
||||
if( this->IsAppSecure )
|
||||
{
|
||||
privateKey = (u8*)g_devPrivKey_DER_secure;
|
||||
publicKey = (u8*)g_devPubKey_DER_secure;
|
||||
}
|
||||
else
|
||||
#endif //METWL_VER_APPTYPE_SECURE
|
||||
#ifdef METWL_VER_APPTYPE_SYSTEM
|
||||
if( this->IsAppSystem )
|
||||
{
|
||||
privateKey = (u8*)g_devPrivKey_DER_system;
|
||||
publicKey = (u8*)g_devPubKey_DER_system;
|
||||
}
|
||||
else
|
||||
#endif //METWL_VER_APPTYPE_SYSTEM
|
||||
#ifdef METWL_VER_APPTYPE_USER
|
||||
{
|
||||
privateKey = (u8*)g_devPrivKey_DER;
|
||||
publicKey = (u8*)g_devPubKey_DER;
|
||||
}
|
||||
#endif //METWL_VER_APPTYPE_USER
|
||||
|
||||
// ダイジェストに署名をかける
|
||||
result = ACSign_Encrypto( signDst, privateKey, &signSrc, sizeof(SignatureData) );
|
||||
if( !result )
|
||||
{
|
||||
throw gcnew System::Exception( "Exception: Fail to calc the hash of the ROM header." );
|
||||
}
|
||||
|
||||
// 署名を解除してダイジェストと一致するかベリファイする
|
||||
result = ACSign_Decrypto( decryptBlock, publicKey, signDst, RSA_KEY_LENGTH );
|
||||
for( pos=0; pos < RSA_KEY_LENGTH; pos++ )
|
||||
{
|
||||
if( decryptBlock[pos] == 0x0 ) // 解除後ブロックから実データをサーチ
|
||||
break;
|
||||
}
|
||||
if( !result || (memcmp( &signSrc, &(decryptBlock[pos+1]), sizeof(SignatureData) ) != 0) )
|
||||
{
|
||||
throw gcnew System::Exception( "Exception: Fail to compare the hash of the ROM header." );
|
||||
}
|
||||
|
||||
// ROMヘッダに署名を上書き
|
||||
memcpy( rh->signature, signDst, RSA_KEY_LENGTH );
|
||||
|
||||
} // ECSrlResult RCSrl::signRomHeader(void)
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// 変換
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// 文字列をバイト配列に変換
|
||||
cli::array<System::Byte>^ TransStringToBytes( System::String ^src, const int len )
|
||||
{
|
||||
cli::array<System::Byte> ^bytes = gcnew cli::array<System::Byte>(len);
|
||||
|
||||
int i;
|
||||
for( i=0; i < len; i++ )
|
||||
{
|
||||
bytes[i] = 0;
|
||||
}
|
||||
|
||||
int j=0;
|
||||
for( i=0; i < src->Length; i++ )
|
||||
{
|
||||
if( (src[i] != ' ') && (j < len) )
|
||||
{
|
||||
bytes[j++] = (System::Byte)src[i];
|
||||
}
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
// 16進文字列をバイト配列に変換
|
||||
cli::array<System::Byte>^ TransHexStringToBytes( System::String ^src, const int len )
|
||||
{
|
||||
cli::array<System::Byte> ^bytes = gcnew cli::array<System::Byte>(len);
|
||||
|
||||
int i;
|
||||
for( i=0; i < len; i++ )
|
||||
{
|
||||
bytes[i] = 0;
|
||||
}
|
||||
|
||||
int j=0;
|
||||
for( i=0; i < src->Length; )
|
||||
{
|
||||
if( src[i] == ' ' )
|
||||
{
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
if( (src[i] != ' ') && (j < len) )
|
||||
{
|
||||
bytes[j++] = System::Byte::Parse(src->Substring(i,2), System::Globalization::NumberStyles::HexNumber);
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
// バイト配列を16進文字列に変換
|
||||
System::String^ TransBytesToHexString( cli::array<System::Byte> ^bytes )
|
||||
{
|
||||
System::String ^str = gcnew System::String("");
|
||||
|
||||
int i;
|
||||
for( i=0; i < bytes->Length; i++ )
|
||||
{
|
||||
System::Byte b = bytes[i];
|
||||
str += System::String::Format( "{0:X02}", (char)b );
|
||||
str += " ";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// GUI
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// ファイルをダイアログで取得
|
||||
// @arg [in] デフォルトのディレクトリ
|
||||
// @arg [in] 拡張子フィルタ
|
||||
// @ret 取得したファイル名 エラーのとき nullptr
|
||||
System::String^ OpenFileUsingDialog( System::String ^defdir, System::String ^filter )
|
||||
{
|
||||
System::Windows::Forms::OpenFileDialog ^dlg = gcnew (System::Windows::Forms::OpenFileDialog);
|
||||
if( System::String::IsNullOrEmpty( defdir ) || !System::IO::Directory::Exists( defdir ) )
|
||||
{
|
||||
dlg->InitialDirectory = System::Environment::GetFolderPath( System::Environment::SpecialFolder::Desktop );
|
||||
}
|
||||
else
|
||||
{
|
||||
dlg->InitialDirectory = defdir; // 前に選んだディレクトリをデフォルトにする
|
||||
}
|
||||
dlg->Filter = filter;
|
||||
dlg->FilterIndex = 1;
|
||||
dlg->RestoreDirectory = true;
|
||||
|
||||
if( dlg->ShowDialog() != System::Windows::Forms::DialogResult::OK )
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
defdir = System::IO::Path::GetDirectoryName( dlg->FileName ); // デフォルトディレクトリの更新
|
||||
return System::String::Copy(dlg->FileName);
|
||||
}
|
||||
|
||||
// セーブするファイルをダイアログで取得
|
||||
// @arg [in] デフォルトのディレクトリ
|
||||
// @arg [in] 拡張子フィルタ
|
||||
// @arg [in] ファイルの拡張子が不正なときに追加するときの正しい拡張子
|
||||
// @ret 取得したファイル名 エラーのとき nullptr
|
||||
System::String^ SaveFileUsingDialog( System::String ^defdir, System::String ^filter, System::String ^extension )
|
||||
{
|
||||
System::String ^retfile;
|
||||
System::Windows::Forms::SaveFileDialog ^dlg = gcnew (System::Windows::Forms::SaveFileDialog);
|
||||
|
||||
if( System::String::IsNullOrEmpty( defdir ) || !System::IO::Directory::Exists( defdir ) )
|
||||
{
|
||||
dlg->InitialDirectory = System::Environment::GetFolderPath( System::Environment::SpecialFolder::Desktop );
|
||||
}
|
||||
else
|
||||
{
|
||||
dlg->InitialDirectory = defdir;
|
||||
}
|
||||
dlg->Filter = filter;
|
||||
dlg->FilterIndex = 1;
|
||||
dlg->RestoreDirectory = true;
|
||||
|
||||
if( dlg->ShowDialog() != System::Windows::Forms::DialogResult::OK )
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
defdir = System::IO::Path::GetDirectoryName( dlg->FileName );
|
||||
retfile = dlg->FileName;
|
||||
if( !System::String::IsNullOrEmpty(extension) && !(dlg->FileName->ToLower()->EndsWith( extension->ToLower() )) )
|
||||
{
|
||||
retfile += extension;
|
||||
}
|
||||
return retfile;
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by app.rc
|
||||
@ -0,0 +1,7 @@
|
||||
// stdafx.cpp : 標準インクルード FingerPrinterTWL.pch のみを
|
||||
// 含むソース ファイルは、プリコンパイル済みヘッダーになります。
|
||||
// stdafx.obj にはプリコンパイル済み型情報が含まれます。
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
// stdafx.h : 標準のシステム インクルード ファイルのインクルード ファイル、または
|
||||
// 参照回数が多く、かつあまり変更されない、プロジェクト専用のインクルード ファイル
|
||||
// を記述します。
|
||||
#pragma once
|
||||
|
||||
// TODO: プログラムに必要な追加ヘッダーをここで参照してください。
|
||||
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user