Let the user decide to convert the txt to the masterkey.bin
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1302 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
3f52c69513
commit
1580d6ecf1
|
@ -175,7 +175,7 @@
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
AdditionalIncludeDirectories="..\Common\Src"
|
AdditionalIncludeDirectories="..\Common\Src;..\..\..\Externals\wxWidgets\Include"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
|
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
|
||||||
RuntimeLibrary="0"
|
RuntimeLibrary="0"
|
||||||
EnableEnhancedInstructionSet="2"
|
EnableEnhancedInstructionSet="2"
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "AES/aes.h"
|
#include "AES/aes.h"
|
||||||
|
#include <wx/wx.h>
|
||||||
|
|
||||||
#include "VolumeCreator.h"
|
#include "VolumeCreator.h"
|
||||||
|
|
||||||
|
@ -127,37 +128,49 @@ IVolume* CreateVolumeFromCryptedWiiImage(IBlobReader& _rReader, u32 _VolumeType)
|
||||||
FILE* pT = fopen(WII_MASTERKEY_FILE, "rb");
|
FILE* pT = fopen(WII_MASTERKEY_FILE, "rb");
|
||||||
if (pT == NULL)
|
if (pT == NULL)
|
||||||
{
|
{
|
||||||
PanicAlert("Can't open '" WII_MASTERKEY_FILE "'.\n If you know the key, now it's the time to paste it into '" WII_MASTERKEY_FILE_HEX "' before pressing [OK].");
|
if (wxMessageBox(_("Can't open '" WII_MASTERKEY_FILE "'.\n If you know the key, now it's the time to paste it into '"
|
||||||
|
WII_MASTERKEY_FILE_HEX "' before pressing [YES]."),
|
||||||
pT = fopen(WII_MASTERKEY_FILE_HEX, "r");
|
wxMessageBoxCaptionStr, wxYES_NO|wxICON_EXCLAMATION) == wxYES)
|
||||||
if(pT==NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
static char hexkey[32];
|
|
||||||
if(fread(hexkey,1,32,pT)<32)
|
|
||||||
{
|
{
|
||||||
|
pT = fopen(WII_MASTERKEY_FILE_HEX, "r");
|
||||||
|
if(pT==NULL){
|
||||||
|
PanicAlert("could not open " WII_MASTERKEY_FILE_HEX );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char hexkey[32];
|
||||||
|
if(fread(hexkey,1,32,pT)<32)
|
||||||
|
{
|
||||||
|
PanicAlert(WII_MASTERKEY_FILE_HEX " is not the right size" );
|
||||||
|
fclose(pT);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
fclose(pT);
|
fclose(pT);
|
||||||
return NULL;
|
|
||||||
|
static char binkey[16];
|
||||||
|
char *t=hexkey;
|
||||||
|
for(int i=0;i<16;i++)
|
||||||
|
{
|
||||||
|
char h[3]={*(t++),*(t++),0};
|
||||||
|
binkey[i] = strtol(h,NULL,16);
|
||||||
|
}
|
||||||
|
|
||||||
|
pT = fopen(WII_MASTERKEY_FILE, "wb");
|
||||||
|
if(pT==NULL){
|
||||||
|
PanicAlert("could not open/make '" WII_MASTERKEY_FILE "' for writing!");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
fwrite(binkey,16,1,pT);
|
||||||
|
fclose(pT);
|
||||||
|
|
||||||
|
pT = fopen(WII_MASTERKEY_FILE, "rb");
|
||||||
|
if(pT==NULL){
|
||||||
|
PanicAlert("could not open '" WII_MASTERKEY_FILE "' for reading!\n did the file get deleted or locked after converting?");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fclose(pT);
|
else
|
||||||
|
|
||||||
static char binkey[16];
|
|
||||||
char *t=hexkey;
|
|
||||||
for(int i=0;i<16;i++)
|
|
||||||
{
|
|
||||||
char h[3]={*(t++),*(t++),0};
|
|
||||||
binkey[i] = strtol(h,NULL,16);
|
|
||||||
}
|
|
||||||
|
|
||||||
pT = fopen(WII_MASTERKEY_FILE, "wb");
|
|
||||||
if(pT==NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
fwrite(binkey,16,1,pT);
|
|
||||||
fclose(pT);
|
|
||||||
|
|
||||||
pT = fopen(WII_MASTERKEY_FILE, "rb");
|
|
||||||
if(pT==NULL)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue