Skip to content

Commit

Permalink
fix unable to download
Browse files Browse the repository at this point in the history
  • Loading branch information
GEEKiDoS committed Jul 27, 2024
1 parent d6a725f commit 3dac12e
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/client/component/iidx/i_overlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace iidx::overlay
ImFont* font_normal;
ImFont* font_big;

int show_information = 0;
int show_information = 1;
bool show_clock = false;
bool show_extra_music_info = true;

Expand Down
62 changes: 40 additions & 22 deletions src/client/component/iidx/i_patches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,46 @@ namespace iidx::patches
}

// bypass ICP registration
utils::hook::detour on_http_request_hook;
bool on_http_request(HINTERNET hRequest, LPCWSTR lpszHeaders, DWORD dwHeadersLength,
LPVOID lpOptional, DWORD dwOptionalLength, DWORD dwTotalLength, DWORD_PTR dwContext
)
utils::hook::detour on_http_connect_hook;
HINTERNET WINAPI on_http_connect(HINTERNET hSession, LPCWSTR pswzServerName, INTERNET_PORT nServerPort, DWORD dwReserved)
{
// ignore cert error
DWORD dwFlags =
SECURITY_FLAG_IGNORE_UNKNOWN_CA |
SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE |
SECURITY_FLAG_IGNORE_CERT_CN_INVALID |
SECURITY_FLAG_IGNORE_CERT_DATE_INVALID;

WinHttpSetOption(hRequest, WINHTTP_OPTION_SECURITY_FLAGS, &dwFlags, sizeof(dwFlags));

// overwrite host
WinHttpAddRequestHeaders(hRequest,
L"Host: tgk-wcaime.wahlap.com",
static_cast<DWORD>(-1),
WINHTTP_ADDREQ_FLAG_REPLACE | WINHTTP_ADDREQ_FLAG_ADD
);
auto connect = on_http_connect_hook.invoke_pascal<HINTERNET>(hSession, pswzServerName, nServerPort, dwReserved);

if (!StrStrW(pswzServerName, L"cloudfront.net"))
{
*(reinterpret_cast<uint32_t*>(connect) + 2) = 0x12345678;
}

return connect;
}

utils::hook::detour on_http_open_request_hook;
HINTERNET WINAPI on_http_open_request(HINTERNET hConnect, LPCWSTR pwszVerb, LPCWSTR pwszObjectName, LPCWSTR pwszVersion, LPCWSTR pwszReferrer, LPCWSTR* ppwszAcceptTypes, DWORD dwFlags)
{
auto request = on_http_open_request_hook.invoke<HINTERNET>(hConnect, pwszVerb, pwszObjectName, pwszVersion, pwszReferrer, ppwszAcceptTypes, dwFlags);

if (*(reinterpret_cast<uint32_t*>(hConnect) + 2) == 0x12345678)
{
*(reinterpret_cast<uint32_t*>(hConnect) + 2) = 0xDDDDDDDD;

// ignore cert error
DWORD dwFlags =

Check warning on line 63 in src/client/component/iidx/i_patches.cpp

View workflow job for this annotation

GitHub Actions / Build binaries (Debug)

declaration of 'dwFlags' hides function parameter [D:\a\client\client\build\client.vcxproj]

Check failure on line 63 in src/client/component/iidx/i_patches.cpp

View workflow job for this annotation

GitHub Actions / Build binaries (Release)

the following warning is treated as an error [D:\a\client\client\build\client.vcxproj]

Check warning on line 63 in src/client/component/iidx/i_patches.cpp

View workflow job for this annotation

GitHub Actions / Build binaries (Release)

declaration of 'dwFlags' hides function parameter [D:\a\client\client\build\client.vcxproj]
SECURITY_FLAG_IGNORE_UNKNOWN_CA |
SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE |
SECURITY_FLAG_IGNORE_CERT_CN_INVALID |
SECURITY_FLAG_IGNORE_CERT_DATE_INVALID;

WinHttpSetOption(request, WINHTTP_OPTION_SECURITY_FLAGS, &dwFlags, sizeof(dwFlags));

// overwrite host
WinHttpAddRequestHeaders(request,
L"Host: tgk-wcaime.wahlap.com",
static_cast<DWORD>(-1),
WINHTTP_ADDREQ_FLAG_REPLACE | WINHTTP_ADDREQ_FLAG_ADD
);
}

return on_http_request_hook.get<decltype(WinHttpSendRequest)>()
(hRequest, lpszHeaders, dwHeadersLength, lpOptional, dwOptionalLength, dwTotalLength, dwContext);
return request;
}

class component final : public component_interface
Expand Down Expand Up @@ -96,7 +113,8 @@ namespace iidx::patches
}

utils::nt::library winhttp{ "winhttp.dll" };
on_http_request_hook.create(winhttp.get_proc<void*>("WinHttpSendRequest"), on_http_request);
on_http_connect_hook.create(winhttp.get_proc<void*>("WinHttpConnect"), on_http_connect);
on_http_open_request_hook.create(winhttp.get_proc<void*>("WinHttpOpenRequest"), on_http_open_request);
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/client/game/iidx/symbols.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace iidx
WEAK symbol<IDirect3DDevice9Ex*> d3d9ex_device{ 0x142AAD3F8 };
WEAK symbol<IDirect3DDevice9*> d3d9_device{ 0x142AAD3F8 };
WEAK symbol<HWND*> main_hwnd{ 0x142AAD3E8 };
WEAK symbol<const char> infinitas_id{ 0x142AAD388 };
WEAK symbol<const char> infinitas_id{ 0x141AC5494 };
WEAK symbol<const char> game_version{ 0x141AC54E3 };

WEAK symbol<bool> show_options{ 0x141ACE104 };
Expand Down
6 changes: 4 additions & 2 deletions src/client/launcher/launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

#include "component/steam_proxy.hpp"

#ifndef _DEBUG
#define USE_EMBEDDED 1

#if !_DEBUG || USE_EMBEDDED
#include "resources/all.hpp"
#endif

Expand Down Expand Up @@ -259,7 +261,7 @@ void launcher::create_main_menu()
}
);

#ifdef _DEBUG
#if _DEBUG && !USE_EMBEDDED
smartview_->set_url("http://localhost:5173/");
smartview_->set_dev_tools(true);
#else
Expand Down

0 comments on commit 3dac12e

Please sign in to comment.