dmnt: trailing whitespace

This commit is contained in:
Michael Scire 2019-06-19 22:20:44 -07:00
parent d7a3645f7f
commit 491383c637
12 changed files with 65 additions and 65 deletions

View file

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <map>
#include <switch.h>
#include "dmnt_config.hpp"
@ -37,14 +37,14 @@ void DmntCheatDebugEventsManager::PerCoreThreadFunc(void *arg) {
g_per_core_queues[current_core]->Receive(&x);
debug_handle = static_cast<Handle>(x);
}
/* Continue the process, if needed. */
if ((GetRuntimeFirmwareVersion() >= FirmwareVersion_300)) {
svcContinueDebugEvent(debug_handle, 5, nullptr, 0);
} else {
svcLegacyContinueDebugEvent(debug_handle, 5, 0);
}
g_continued_signal.Signal();
}
}
@ -55,7 +55,7 @@ void DmntCheatDebugEventsManager::ContinueCheatProcess(Handle cheat_dbg_hnd) {
while (R_SUCCEEDED(svcGetDebugEvent((u8 *)&dbg_event, cheat_dbg_hnd))) {
/* ... */
}
size_t target_core = DmntCheatDebugEventsManager::NumCores - 1;
/* Retrieve correct core for new thread event. */
if (dbg_event.type == DebugEventType::AttachThread) {
@ -65,14 +65,14 @@ void DmntCheatDebugEventsManager::ContinueCheatProcess(Handle cheat_dbg_hnd) {
if (R_FAILED(rc)) {
fatalSimple(rc);
}
target_core = out32;
}
/* Make appropriate thread continue. */
g_per_core_queues[target_core]->Send(static_cast<uintptr_t>(cheat_dbg_hnd));
/* Wait. */
g_continued_signal.Wait();
g_continued_signal.Reset();
@ -83,17 +83,17 @@ void DmntCheatDebugEventsManager::Initialize() {
for (size_t i = 0; i < DmntCheatDebugEventsManager::NumCores; i++) {
/* Create queue. */
g_per_core_queues[i] = new HosMessageQueue(1);
/* Create thread. */
if (R_FAILED(g_per_core_threads[i].Initialize(&DmntCheatDebugEventsManager::PerCoreThreadFunc, reinterpret_cast<void *>(i), 0x1000, 24, i))) {
std::abort();
}
/* Set core mask. */
if (R_FAILED(svcSetThreadCoreMask(g_per_core_threads[i].GetHandle(), i, (1u << i)))) {
std::abort();
}
/* Start thread. */
if (R_FAILED(g_per_core_threads[i].Start())) {
std::abort();

View file

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <switch.h>
#include <stratosphere.hpp>
@ -126,6 +126,6 @@ class DmntCheatDebugEventsManager {
static void PerCoreThreadFunc(void *arg);
public:
static void ContinueCheatProcess(Handle cheat_dbg_hnd);
static void Initialize();
};

View file

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <switch.h>
#include <stratosphere.hpp>
@ -30,14 +30,14 @@ class DmntCheatManager {
static void DetectThread(void *arg);
static void VmThread(void *arg);
static void DebugEventsThread(void *arg);
static void StartDebugEventsThread();
static void WaitDebugEventsThread();
static bool HasActiveCheatProcess();
static void CloseActiveCheatProcess();
static void ContinueCheatProcess();
static void ResetCheatEntry(size_t i);
static void ResetAllCheatEntries();
static CheatEntry *GetFreeCheatEntry();
@ -49,35 +49,35 @@ class DmntCheatManager {
static bool ParseCheatToggles(const char *s, size_t len);
static bool LoadCheatToggles(u64 title_id);
static void SaveCheatToggles(u64 title_id);
static void ResetFrozenAddresses();
public:
static bool GetHasActiveCheatProcess();
static Handle GetCheatProcessEventHandle();
static Result GetCheatProcessMetadata(CheatProcessMetadata *out);
static Result ForceOpenCheatProcess();
static Result ReadCheatProcessMemoryForVm(u64 proc_addr, void *out_data, size_t size);
static Result WriteCheatProcessMemoryForVm(u64 proc_addr, const void *data, size_t size);
static Result GetCheatProcessMappingCount(u64 *out_count);
static Result GetCheatProcessMappings(MemoryInfo *mappings, size_t max_count, u64 *out_count, u64 offset);
static Result ReadCheatProcessMemory(u64 proc_addr, void *out_data, size_t size);
static Result WriteCheatProcessMemory(u64 proc_addr, const void *data, size_t size);
static Result QueryCheatProcessMemory(MemoryInfo *mapping, u64 address);
static Result GetCheatCount(u64 *out_count);
static Result GetCheats(CheatEntry *cheats, size_t max_count, u64 *out_count, u64 offset);
static Result GetCheatById(CheatEntry *out_cheat, u32 cheat_id);
static Result ToggleCheat(u32 cheat_id);
static Result AddCheat(u32 *out_id, CheatDefinition *def, bool enabled);
static Result RemoveCheat(u32 cheat_id);
static Result GetFrozenAddressCount(u64 *out_count);
static Result GetFrozenAddresses(FrozenAddressEntry *frz_addrs, size_t max_count, u64 *out_count, u64 offset);
static Result GetFrozenAddress(FrozenAddressEntry *frz_addr, u64 address);
static Result EnableFrozenAddress(u64 *out_value, u64 address, u64 width);
static Result DisableFrozenAddress(u64 address);
static void InitializeCheatManager();
};

View file

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <switch.h>
#include <stratosphere.hpp>
@ -26,14 +26,14 @@ enum DmntCheatCmd {
DmntCheat_Cmd_GetCheatProcessEvent = 65001,
DmntCheat_Cmd_GetCheatProcessMetadata = 65002,
DmntCheat_Cmd_ForceOpenCheatProcess = 65003,
/* Interact with Memory */
DmntCheat_Cmd_GetCheatProcessMappingCount = 65100,
DmntCheat_Cmd_GetCheatProcessMappings = 65101,
DmntCheat_Cmd_ReadCheatProcessMemory = 65102,
DmntCheat_Cmd_WriteCheatProcessMemory = 65103,
DmntCheat_Cmd_QueryCheatProcessMemory = 65104,
/* Interact with Cheats */
DmntCheat_Cmd_GetCheatCount = 65200,
DmntCheat_Cmd_GetCheats = 65201,
@ -41,7 +41,7 @@ enum DmntCheatCmd {
DmntCheat_Cmd_ToggleCheat = 65203,
DmntCheat_Cmd_AddCheat = 65204,
DmntCheat_Cmd_RemoveCheat = 65205,
/* Interact with Frozen Addresses */
DmntCheat_Cmd_GetFrozenAddressCount = 65300,
DmntCheat_Cmd_GetFrozenAddresses = 65301,
@ -56,20 +56,20 @@ class DmntCheatService final : public IServiceObject {
void GetCheatProcessEvent(Out<CopiedHandle> out_event);
Result GetCheatProcessMetadata(Out<CheatProcessMetadata> out_metadata);
Result ForceOpenCheatProcess();
Result GetCheatProcessMappingCount(Out<u64> out_count);
Result GetCheatProcessMappings(OutBuffer<MemoryInfo> mappings, Out<u64> out_count, u64 offset);
Result ReadCheatProcessMemory(OutBuffer<u8> buffer, u64 address, u64 out_size);
Result WriteCheatProcessMemory(InBuffer<u8> buffer, u64 address, u64 in_size);
Result QueryCheatProcessMemory(Out<MemoryInfo> mapping, u64 address);
Result GetCheatCount(Out<u64> out_count);
Result GetCheats(OutBuffer<CheatEntry> cheats, Out<u64> out_count, u64 offset);
Result GetCheatById(OutBuffer<CheatEntry> cheat, u32 cheat_id);
Result ToggleCheat(u32 cheat_id);
Result AddCheat(InBuffer<CheatDefinition> cheat, Out<u32> out_cheat_id, bool enabled);
Result RemoveCheat(u32 cheat_id);
Result GetFrozenAddressCount(Out<u64> out_count);
Result GetFrozenAddresses(OutBuffer<FrozenAddressEntry> addresses, Out<u64> out_count, u64 offset);
Result GetFrozenAddress(Out<FrozenAddressEntry> entry, u64 address);

View file

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <switch.h>
#include <stratosphere.hpp>

View file

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <switch.h>
#include <stdarg.h>
@ -31,16 +31,16 @@ enum CheatVmOpcodeType : u32 {
CheatVmOpcodeType_StoreStaticToAddress = 6,
CheatVmOpcodeType_PerformArithmeticStatic = 7,
CheatVmOpcodeType_BeginKeypressConditionalBlock = 8,
/* These are not implemented by Gateway's VM. */
CheatVmOpcodeType_PerformArithmeticRegister = 9,
CheatVmOpcodeType_StoreRegisterToAddress = 10,
CheatVmOpcodeType_Reserved11 = 11,
/* This is a meta entry, and not a real opcode. */
/* This is to facilitate multi-nybble instruction decoding. */
CheatVmOpcodeType_ExtendedWidth = 12,
/* Extended width opcodes. */
CheatVmOpcodeType_BeginRegisterConditionalBlock = 0xC0,
CheatVmOpcodeType_SaveRestoreRegister = 0xC1,
@ -49,7 +49,7 @@ enum CheatVmOpcodeType : u32 {
/* This is a meta entry, and not a real opcode. */
/* This is to facilitate multi-nybble instruction decoding. */
CheatVmOpcodeType_DoubleExtendedWidth = 0xF0,
/* Double-extended width opcodes. */
CheatVmOpcodeType_DebugLog = 0xFFF,
};
@ -74,13 +74,13 @@ enum RegisterArithmeticType : u32 {
RegisterArithmeticType_Multiplication = 2,
RegisterArithmeticType_LeftShift = 3,
RegisterArithmeticType_RightShift = 4,
/* These are not supported by Gateway's VM. */
RegisterArithmeticType_LogicalAnd = 5,
RegisterArithmeticType_LogicalOr = 6,
RegisterArithmeticType_LogicalNot = 7,
RegisterArithmeticType_LogicalXor = 8,
RegisterArithmeticType_None = 9,
};
@ -276,25 +276,25 @@ class DmntCheatVm {
bool DecodeNextOpcode(CheatVmOpcode *out);
void SkipConditionalBlock();
void ResetState();
/* For implementing the DebugLog opcode. */
void DebugLog(u32 log_id, u64 value);
/* For debugging. These will be IFDEF'd out normally. */
void OpenDebugLogFile();
void CloseDebugLogFile();
void LogToDebugFile(const char *format, ...);
void LogOpcode(const CheatVmOpcode *opcode);
static u64 GetVmInt(VmInt value, u32 bit_width);
static u64 GetCheatProcessAddress(const CheatProcessMetadata* metadata, MemoryAccessType mem_type, u64 rel_address);
public:
DmntCheatVm() { }
size_t GetProgramSize() {
return this->num_opcodes;
}
bool LoadProgram(const CheatEntry *cheats, size_t num_cheats);
void Execute(const CheatProcessMetadata *metadata);
#ifdef DMNT_CHEAT_VM_DEBUG_LOG

View file

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <switch.h>
#include <string.h>
#include <stratosphere.hpp>
@ -33,7 +33,7 @@ static char g_config_ini_data[0x800];
static OverrideKey ParseOverrideKey(const char *value) {
OverrideKey cfg;
/* Parse on by default. */
if (value[0] == '!') {
cfg.override_by_default = true;
@ -41,7 +41,7 @@ static OverrideKey ParseOverrideKey(const char *value) {
} else {
cfg.override_by_default = false;
}
/* Parse key combination. */
if (strcasecmp(value, "A") == 0) {
cfg.key_combination = KEY_A;
@ -82,7 +82,7 @@ static OverrideKey ParseOverrideKey(const char *value) {
} else {
cfg.key_combination = 0;
}
return cfg;
}
@ -101,7 +101,7 @@ static int DmntIniHandler(void *user, const char *section, const char *name, con
static int DmntTitleSpecificIniHandler(void *user, const char *section, const char *name, const char *value) {
/* We'll output an override key when relevant. */
OverrideKey *user_cfg = reinterpret_cast<OverrideKey *>(user);
if (strcasecmp(section, "override_config") == 0) {
if (strcasecmp(name, "cheat_enable_key") == 0) {
*user_cfg = ParseOverrideKey(value);
@ -117,20 +117,20 @@ void DmntConfigManager::RefreshConfiguration() {
if (config == NULL) {
return;
}
memset(g_config_ini_data, 0, sizeof(g_config_ini_data));
fread(g_config_ini_data, 1, sizeof(g_config_ini_data) - 1, config);
fclose(config);
ini_parse_string(g_config_ini_data, DmntIniHandler, NULL);
}
OverrideKey DmntConfigManager::GetTitleCheatEnableKey(u64 tid) {
OverrideKey cfg = g_default_cheat_enable_key;
char path[FS_MAX_PATH+1] = {0};
snprintf(path, FS_MAX_PATH, "sdmc:/atmosphere/titles/%016lx/config.ini", tid);
snprintf(path, FS_MAX_PATH, "sdmc:/atmosphere/titles/%016lx/config.ini", tid);
FILE *config = fopen(path, "r");
if (config != NULL) {
ON_SCOPE_EXIT { fclose(config); };
@ -138,7 +138,7 @@ OverrideKey DmntConfigManager::GetTitleCheatEnableKey(u64 tid) {
/* Parse current title ini. */
ini_parse_file(config, DmntTitleSpecificIniHandler, &cfg);
}
return cfg;
}
@ -151,7 +151,7 @@ static bool HasOverrideKey(OverrideKey *cfg) {
bool DmntConfigManager::HasCheatEnableButton(u64 tid) {
/* Unconditionally refresh loader.ini contents. */
RefreshConfiguration();
OverrideKey title_cfg = GetTitleCheatEnableKey(tid);
return HasOverrideKey(&title_cfg);
}

View file

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <switch.h>
@ -25,7 +25,7 @@ struct OverrideKey {
class DmntConfigManager {
public:
static void RefreshConfiguration();
static OverrideKey GetTitleCheatEnableKey(u64 tid);
static bool HasCheatEnableButton(u64 tid);
};

View file

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <switch.h>
#include <string.h>
#include <stratosphere.hpp>
@ -24,13 +24,13 @@ static HosMutex g_hid_keys_down_lock;
Result HidManagement::GetKeysDown(u64 *keys) {
std::scoped_lock<HosMutex> lk(g_hid_keys_down_lock);
hidScanInput();
*keys = 0;
for (int controller = 0; controller < 10; controller++) {
*keys |= hidKeysHeld((HidControllerID) controller);
}
return ResultSuccess;
}

View file

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <switch.h>

View file

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <switch.h>
#include <stratosphere.hpp>
@ -81,7 +81,7 @@ class DebugMonitorService final : public IServiceObject {
Result GetProcessId(Out<u64> out_pid, Handle hnd);
Result GetProcessHandle(Out<Handle> out_hnd, u64 pid);
Result WaitSynchronization(Handle hnd, u64 ns);
Result TargetIO_FileOpen(OutBuffer<u64> out_hnd, InBuffer<char> path, int open_mode, u32 create_mode);
Result TargetIO_FileClose(InBuffer<u64> hnd);
Result TargetIO_FileRead(InBuffer<u64> hnd, OutBuffer<u8, BufferType_Type1> out_data, Out<u32> out_read, u64 offset);

View file

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <switch.h>
#include "pm_shim.h"
@ -53,7 +53,7 @@ Result pmdmntAtmosphereGetProcessInfo(Handle* out, u64 *tid_out, FsStorageId *si
if (R_SUCCEEDED(rc)) {
if (out) {
*out = r.Handles[0];
*out = r.Handles[0];
} else {
svcCloseHandle(r.Handles[0]);
}