mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@661 385bec56-5757-e545-9c3a-d8741f4650f1
183 lines
4.8 KiB
C++
183 lines
4.8 KiB
C++
/*---------------------------------------------------------------------------*
|
||
Project: Horizon
|
||
File: Util.h
|
||
|
||
Copyright 2009 Nintendo. All rights reserved.
|
||
|
||
These coded instructions, statements, and computer programs contain
|
||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||
Company Ltd., and are protected by Federal copyright law. They may
|
||
not be disclosed to third parties or copied or duplicated in any form,
|
||
in whole or in part, without the prior written consent of Nintendo.
|
||
|
||
$Rev$
|
||
*---------------------------------------------------------------------------*/
|
||
|
||
#ifndef UTIL_H_
|
||
#define UTIL_H_
|
||
|
||
#include <string>
|
||
#include <nn.h>
|
||
#include <nn/cfg/CTR/cfg_ApiSys.h>
|
||
#include <nn/mcu.h>
|
||
#include <nn/nwm.h>
|
||
|
||
#include "VersionDetect.h"
|
||
|
||
namespace common
|
||
{
|
||
|
||
class Util
|
||
{
|
||
public:
|
||
Util();
|
||
virtual ~Util();
|
||
|
||
void InitializeForBackup();
|
||
void InitializeForRestore();
|
||
|
||
void FinalizeForBackup();
|
||
void FinalizeForRestore();
|
||
|
||
// シリアルナンバーにモジュラス10 ウェイト3・1(M10W31)でチェックデジットを付加する
|
||
void AddCheckDigit(char* serial);
|
||
|
||
// IVSから計算されるセーブデータディレクトリ名を取得する
|
||
static void GetSaveDataDirectoryRoot(::std::string& sysSaveRoot);
|
||
|
||
// ACアダプタが接続されているかどうか
|
||
bool IsAdapterConnected();
|
||
|
||
// バッテリ残量が10%未満かどうか
|
||
bool IsBatteryLower();
|
||
|
||
// IVSを読み取れるかどうか
|
||
bool CanReadIVS();
|
||
|
||
// シリアルナンバーを読み取れるかどうか
|
||
bool CanReadSerialNumber();
|
||
|
||
// シリアルナンバーを取得する
|
||
void GetSerialNumber(u8** serial, size_t* size);
|
||
|
||
// シリアルナンバーを返す
|
||
u8* GetSerialNumber();
|
||
|
||
// チェックデジット無しのシリアルナンバーを取得する
|
||
void GetSerialNumberWithoutCD(u8* serial);
|
||
|
||
// IVSを取得する
|
||
void GetIvs(void** ivs, size_t* size);
|
||
|
||
// 32bitデバイスIDを返す
|
||
bit32 GetDeviceId();
|
||
|
||
// CUPメジャーバージョンを返す
|
||
u8 GetCupMajorVersion();
|
||
|
||
// CUPマイナーバージョンを返す
|
||
u8 GetCupMinorVersion();
|
||
|
||
// CUPマイクロバージョンを返す
|
||
u8 GetCupMicroVersion();
|
||
|
||
// NUPバージョンを返す
|
||
u8 GetNupVersion();
|
||
|
||
// MCUプロセスに接続するためのハンドルを返す
|
||
nn::Handle GetMcuHandle();
|
||
|
||
// バッテリ残量を0~100で返す
|
||
u32 GetBatteryRemain();
|
||
|
||
// 64bitインフラデバイスIDを返す
|
||
u64 GetInfraDeviceId();
|
||
|
||
// フレンドコードを返す
|
||
u64 GetFriendcode();
|
||
|
||
// MACアドレスを返す
|
||
char8* GetMacAddress();
|
||
|
||
// リージョンコードを返す
|
||
nn::cfg::CTR::CfgRegionCode GetRegion();
|
||
|
||
// リージョンコードを3文字のアルファベットに置き換えた文字列を返す
|
||
const char* GetRegionCodeA3();
|
||
|
||
// バージョン情報を取得する
|
||
void GetVersionData(common::VerDef* version);
|
||
|
||
// フレンドコードを取得済みかどうか
|
||
bool HasReadFriendCode();
|
||
|
||
// デバイスIDを4文字ごとに空白で区切る
|
||
static void SplitDeviceidWithSpace(std::string& deviceIdStr);
|
||
|
||
// 現在の描画先ディスプレイを返す
|
||
// target NN_GX_DISPLAY0 または NN_GX_DISPLAY1
|
||
// flip 上下画面を入れ替えているかどうか
|
||
static u32 GetRenderTarget(u32 target, bool flip = false);
|
||
|
||
private:
|
||
void Initialize();
|
||
void Finalize();
|
||
void ReadIvs(u8 cupMajorVersion);
|
||
|
||
NN_PADDING4;
|
||
// フレンドコード
|
||
u64 m_FriendCode;
|
||
|
||
// バージョン情報
|
||
common::VerDef m_VerData;
|
||
|
||
// mcu接続のためのハンドル
|
||
nn::Handle m_McuSession;
|
||
|
||
// デバイスID
|
||
bit32 m_DeviceId;
|
||
|
||
// IVSへのポインタ
|
||
void* mp_Ivs;
|
||
|
||
// IVSのサイズ
|
||
size_t m_SizeofIvs;
|
||
// チェックデジット無しのシリアルナンバーの長さ
|
||
size_t m_SerialNoWithoutCGLen;
|
||
|
||
// MCUへのポインタ
|
||
nn::mcu::CTR::HwCheck* mp_Mcu;
|
||
|
||
// リージョン
|
||
nn::cfg::CTR::CfgRegionCode m_Region;
|
||
|
||
// バッテリ残量
|
||
u8 m_BatteryRemain;
|
||
|
||
// シリアルナンバーが読めるかどうか
|
||
bool m_CanReadSerialNumber;
|
||
|
||
// IVSが読めるかどうか
|
||
bool m_CanReadIvs;
|
||
|
||
// シリアルナンバー
|
||
u8 m_SerialNo[nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN];
|
||
|
||
// MACアドレス
|
||
char8 m_MacAddress[nn::nwm::Mac::MAC_STRING_SIZE];
|
||
NN_PADDING3;
|
||
|
||
// FriendCodeを読んだかどうか
|
||
bool m_HasReadFriendCode;
|
||
NN_PADDING3;
|
||
NN_PADDING4;
|
||
|
||
};
|
||
|
||
nn::Result InitializeNetwork(void);
|
||
nn::Result FinalizeNetwork(void);
|
||
|
||
}
|
||
|
||
#endif /* UTIL_H_ */
|