Skip to content

Commit

Permalink
Added a DashLaunch class to interact with the DashLaunch config
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementDreptin committed Nov 6, 2022
1 parent 98a38ae commit 773a410
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 0 deletions.
2 changes: 2 additions & 0 deletions XexUtils.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
</Lib>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="include\DashLaunch.h" />
<ClInclude Include="include\Detour.h" />
<ClInclude Include="include\Log.h" />
<ClInclude Include="include\Socket.h" />
Expand All @@ -74,6 +75,7 @@
<ClInclude Include="include\Xam_.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\DashLaunch.cpp" />
<ClCompile Include="src\Detour.cpp" />
<ClCompile Include="src\Log.cpp" />
<ClCompile Include="src\Math_.cpp" />
Expand Down
6 changes: 6 additions & 0 deletions XexUtils.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
<ClCompile Include="src\Socket.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\DashLaunch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\pch.h">
Expand Down Expand Up @@ -88,6 +91,9 @@
<ClInclude Include="include\Socket.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\DashLaunch.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include=".editorconfig" />
Expand Down
35 changes: 35 additions & 0 deletions examples/DashLaunch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# DashLaunch

Get and set a DashLaunch option value by its name:
```C++
void Init()
{
// Initialize the DashLaunch functions
HRESULT hr = XexUtils::DashLaunch::Init();
if (FAILED(hr))
{
XexUtils::Log::Error("Couldn't get functions from DashLaunch");
return;
}

// Force liveblock to be enabled
uint32_t liveBlockEnabled = 0;
BOOL result = XexUtils::DashLaunch::GetOptionValueByName("liveblock", &liveBlockEnabled);
if (result == FALSE)
{
XexUtils::Log::Error("Couldn't get the liveblock value from DashLaunch");
return;
}

if (liveBlockEnabled == 0)
{
uint32_t enableLiveBlock = 1;
result = XexUtils::DashLaunch::SetOptionValueByName("liveblock", &enableLiveBlock);
if (result == FALSE)
{
XexUtils::Log::Error("Couldn't enable liveblock");
return;
}
}
}
```
22 changes: 22 additions & 0 deletions include/DashLaunch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

namespace XexUtils
{

typedef BOOL (*DLAUNCHGETOPTVALBYNAME)(const char *optionName, uint32_t *pOptionValue);
typedef BOOL (*DLAUNCHSETOPTVALBYNAME)(const char *optionName, uint32_t *pOptionValue);

class DashLaunch
{
public:
// Get the pointers to the DashLaunch functions.
static HRESULT Init();

// Get the value of optionName as a uint32_t, 1 for true, 0 for false, pointer to the first character for strings.
static DLAUNCHGETOPTVALBYNAME GetOptionValueByName;

// Set the value of optionName as a uint32_t, 1 for true, 0 for false, pointer to the first character for strings.
static DLAUNCHSETOPTVALBYNAME SetOptionValueByName;
};

}
1 change: 1 addition & 0 deletions include/XexUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
#include "Xam_.h"
#include "SMC.h"
#include "Socket.h"
#include "DashLaunch.h"
#include "Log.h"
33 changes: 33 additions & 0 deletions src/DashLaunch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include "pch.h"
#include "DashLaunch.h"

#include "Memory.h"

#define LAUNCH_MODULE "launch.xex"

namespace XexUtils
{

enum
{
DL_ORDINALS_GETOPTVALBYNAME = 9,
DL_ORDINALS_SETOPTVALBYNAME = 10,
};

DLAUNCHGETOPTVALBYNAME DashLaunch::GetOptionValueByName = nullptr;
DLAUNCHSETOPTVALBYNAME DashLaunch::SetOptionValueByName = nullptr;

HRESULT DashLaunch::Init()
{
GetOptionValueByName = static_cast<DLAUNCHGETOPTVALBYNAME>(Memory::ResolveFunction(LAUNCH_MODULE, DL_ORDINALS_GETOPTVALBYNAME));
if (GetOptionValueByName == nullptr)
return E_FAIL;

SetOptionValueByName = static_cast<DLAUNCHSETOPTVALBYNAME>(Memory::ResolveFunction(LAUNCH_MODULE, DL_ORDINALS_SETOPTVALBYNAME));
if (SetOptionValueByName == nullptr)
return E_FAIL;

return S_OK;
}

}

0 comments on commit 773a410

Please sign in to comment.