mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 22:29:39 -06:00
Merge pull request #3859 from Aestek/feature/netplay-md5
Netplay: add md5 testing
This commit is contained in:
@ -30,6 +30,7 @@ set(SRCS Analytics.cpp
|
||||
Version.cpp
|
||||
x64ABI.cpp
|
||||
x64Emitter.cpp
|
||||
MD5.cpp
|
||||
Crypto/bn.cpp
|
||||
Crypto/ec.cpp
|
||||
Logging/LogManager.cpp)
|
||||
|
@ -114,6 +114,7 @@
|
||||
<ClInclude Include="JitRegister.h" />
|
||||
<ClInclude Include="LinearDiskCache.h" />
|
||||
<ClInclude Include="MathUtil.h" />
|
||||
<ClInclude Include="MD5.h" />
|
||||
<ClInclude Include="MemArena.h" />
|
||||
<ClInclude Include="MemoryUtil.h" />
|
||||
<ClInclude Include="MsgHandler.h" />
|
||||
@ -158,6 +159,7 @@
|
||||
<ClCompile Include="JitRegister.cpp" />
|
||||
<ClCompile Include="Logging\ConsoleListenerWin.cpp" />
|
||||
<ClCompile Include="MathUtil.cpp" />
|
||||
<ClCompile Include="MD5.cpp" />
|
||||
<ClCompile Include="MemArena.cpp" />
|
||||
<ClCompile Include="MemoryUtil.cpp" />
|
||||
<ClCompile Include="Misc.cpp" />
|
||||
|
@ -118,6 +118,8 @@
|
||||
|
||||
#define WII_STATE "state.dat"
|
||||
|
||||
#define WII_SDCARD "sd.raw"
|
||||
|
||||
#define WII_SETTING "setting.txt"
|
||||
|
||||
#define GECKO_CODE_HANDLER "codehandler.bin"
|
||||
|
@ -793,6 +793,7 @@ static void RebuildUserDirectories(unsigned int dir_index)
|
||||
s_user_paths[F_ARAMDUMP_IDX] = s_user_paths[D_DUMP_IDX] + ARAM_DUMP;
|
||||
s_user_paths[F_FAKEVMEMDUMP_IDX] = s_user_paths[D_DUMP_IDX] + FAKEVMEM_DUMP;
|
||||
s_user_paths[F_GCSRAM_IDX] = s_user_paths[D_GCUSER_IDX] + GC_SRAM;
|
||||
s_user_paths[F_WIISDCARD_IDX] = s_user_paths[D_WIIROOT_IDX] + DIR_SEP WII_SDCARD;
|
||||
|
||||
s_user_paths[D_MEMORYWATCHER_IDX] = s_user_paths[D_USER_IDX] + MEMORYWATCHER_DIR DIR_SEP;
|
||||
s_user_paths[F_MEMORYWATCHERLOCATIONS_IDX] =
|
||||
|
@ -55,6 +55,7 @@ enum
|
||||
F_GCSRAM_IDX,
|
||||
F_MEMORYWATCHERLOCATIONS_IDX,
|
||||
F_MEMORYWATCHERSOCKET_IDX,
|
||||
F_WIISDCARD_IDX,
|
||||
NUM_PATH_INDICES
|
||||
};
|
||||
|
||||
|
52
Source/Core/Common/MD5.cpp
Normal file
52
Source/Core/Common/MD5.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
// Copyright 2016 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <mbedtls/md5.h>
|
||||
#include <string>
|
||||
|
||||
#include "Common/MD5.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "DiscIO/Blob.h"
|
||||
|
||||
namespace MD5
|
||||
{
|
||||
std::string MD5Sum(const std::string& file_path, std::function<bool(int)> report_progress)
|
||||
{
|
||||
std::string output_string;
|
||||
std::vector<u8> data(8 * 1024 * 1024);
|
||||
u64 read_offset = 0;
|
||||
mbedtls_md5_context ctx;
|
||||
|
||||
std::unique_ptr<DiscIO::IBlobReader> file(DiscIO::CreateBlobReader(file_path));
|
||||
u64 game_size = file->GetDataSize();
|
||||
|
||||
mbedtls_md5_starts(&ctx);
|
||||
|
||||
while (read_offset < game_size)
|
||||
{
|
||||
size_t read_size = std::min(static_cast<u64>(data.size()), game_size - read_offset);
|
||||
if (!file->Read(read_offset, read_size, data.data()))
|
||||
return output_string;
|
||||
|
||||
mbedtls_md5_update(&ctx, data.data(), read_size);
|
||||
read_offset += read_size;
|
||||
|
||||
int progress =
|
||||
static_cast<int>(static_cast<float>(read_offset) / static_cast<float>(game_size) * 100);
|
||||
if (!report_progress(progress))
|
||||
return output_string;
|
||||
}
|
||||
|
||||
std::array<u8, 16> output;
|
||||
mbedtls_md5_finish(&ctx, output.data());
|
||||
|
||||
// Convert to hex
|
||||
for (u8 n : output)
|
||||
output_string += StringFromFormat("%02x", n);
|
||||
|
||||
return output_string;
|
||||
}
|
||||
}
|
13
Source/Core/Common/MD5.h
Normal file
13
Source/Core/Common/MD5.h
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright 2016 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
namespace MD5
|
||||
{
|
||||
std::string MD5Sum(const std::string& file_name, std::function<bool(int)> progress);
|
||||
}
|
Reference in New Issue
Block a user