v1.0.7
- Fixed crash related to autoupdater
This commit is contained in:
parent
005ac5f261
commit
e370cb44ad
@ -1,21 +1,29 @@
|
||||
#include <Windows.h>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
|
||||
#include "injector/injector.h"
|
||||
|
||||
|
||||
int main( ) {
|
||||
util::logo::create_console_and_draw_logo( );
|
||||
STARTUPINFO si = { .cb = sizeof( STARTUPINFO ) };
|
||||
|
||||
STARTUPINFOA si = { .cb = sizeof( si ) };
|
||||
PROCESS_INFORMATION pi = {};
|
||||
|
||||
util::logger::debug( "Spawning oSpotify.exe" );
|
||||
if ( !CreateProcessW( L"oSpotify.exe", NULL, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &si, &pi ) ) {
|
||||
constexpr const char* exe_path = "oSpotify.exe";
|
||||
|
||||
// Creating process
|
||||
//
|
||||
util::logger::debug( "Spawning %s", exe_path );
|
||||
if ( !CreateProcessA( exe_path, NULL, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &si, &pi ) ) {
|
||||
util::logger::error( "Unable to create process, error code: %d", GetLastError( ) );
|
||||
system( "pause" );
|
||||
goto END;
|
||||
}
|
||||
|
||||
// Injecting Unspotify
|
||||
//
|
||||
util::logger::debug( "Injecting spotify-reverse.dll" );
|
||||
if ( !injector::inject( pi.hProcess, "spotify-reverse.dll" ) ) {
|
||||
util::logger::error( "Unable to inject module, error code: %d", GetLastError( ) );
|
||||
@ -25,6 +33,7 @@ int main( ) {
|
||||
}
|
||||
|
||||
ResumeThread(pi.hThread);
|
||||
|
||||
END:
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>ClangCL</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<LLVMToolsVersion>12.0.0</LLVMToolsVersion>
|
||||
</PropertyGroup>
|
||||
@ -44,7 +44,7 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>ClangCL</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<LLVMToolsVersion>12.0.0</LLVMToolsVersion>
|
||||
</PropertyGroup>
|
||||
@ -110,14 +110,12 @@
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
<AdditionalOptions>-Xclang -Ofast -Xclang -fno-threadsafe-statics -Xclang -fdelayed-template-parsing -fcf-protection=none -mllvm -pgso -Wno-missing-braces -Wno-deprecated-volatile -Wno-missing-field-initializers -Wno-ignored-pragma-optimize /clang:-fno-unwind-tables /clang:-ffast-math /clang:-fno-builtin -Wno-gnu-string-literal-operator-template -Wno-unused-private-field -Wno-invalid-token-paste -Wno-microsoft-cast -Wno-unused-command-line-argument -Wno-pragma-once-outside-header %(AdditionalOptions)</AdditionalOptions>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalOptions>/MAP /MERGE:.voltbl=.data /MERGE:.retplne=.data /MERGE:.gehcont=.data /MERGE:.00cfg=.data /MERGE:_RDATA=.rdata /FORCE:UNRESOLVED %(AdditionalOptions)</AdditionalOptions>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
@ -150,14 +148,12 @@
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
<AdditionalOptions>-Xclang -Ofast -Xclang -fno-threadsafe-statics -Xclang -fdelayed-template-parsing -fcf-protection=none -mllvm -pgso -Wno-missing-braces -Wno-deprecated-volatile -Wno-missing-field-initializers -Wno-ignored-pragma-optimize /clang:-fno-unwind-tables /clang:-ffast-math /clang:-fno-builtin -Wno-gnu-string-literal-operator-template -Wno-unused-private-field -Wno-invalid-token-paste -Wno-microsoft-cast -Wno-unused-command-line-argument -Wno-pragma-once-outside-header %(AdditionalOptions)</AdditionalOptions>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalOptions>/MAP /MERGE:.voltbl=.data /MERGE:.retplne=.data /MERGE:.gehcont=.data /MERGE:.00cfg=.data /MERGE:_RDATA=.rdata /FORCE:UNRESOLVED %(AdditionalOptions)</AdditionalOptions>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@ -188,6 +184,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="injector\injector.h" />
|
||||
<ClInclude Include="util\util.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
@ -26,5 +26,8 @@
|
||||
<ClInclude Include="injector\injector.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="util\util.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -2,8 +2,8 @@
|
||||
|
||||
// autoupdates
|
||||
|
||||
// @note: es3n1n: v1.0.5 = 105
|
||||
#define UNSPOTIFY_VERSION 106
|
||||
// @note: es3n1n: v1.0.7 = 107
|
||||
#define UNSPOTIFY_VERSION 107
|
||||
|
||||
#define AUTOUPDATER_DOMAIN "es3n.in"
|
||||
#define AUTOUPDATER_URL "unspotify.json"
|
||||
|
@ -3,11 +3,11 @@
|
||||
|
||||
namespace updates {
|
||||
update_info_t poll_info( ) {
|
||||
auto data = util::networking::get( AUTOUPDATER_DOMAIN, AUTOUPDATER_URL );
|
||||
if ( data.find( "error" ) != data.end( ) )
|
||||
auto [data, error] = util::networking::get( AUTOUPDATER_DOMAIN, AUTOUPDATER_URL );
|
||||
if ( error )
|
||||
return update_info_t {
|
||||
.m_error = true,
|
||||
.m_error_desc = data[ "error" ].get<std::string>( )
|
||||
.m_error_desc = "Internal server error :shrug:"
|
||||
};
|
||||
|
||||
return update_info_t {
|
||||
|
@ -3,18 +3,18 @@
|
||||
|
||||
namespace util {
|
||||
namespace networking {
|
||||
nlohmann::json get( const char* domain, const char* url ) {
|
||||
errorable_json_result get( const char* domain, const char* url ) {
|
||||
std::string response_data = err_json_data;
|
||||
|
||||
auto internet_session = InternetOpenA( "Unspotify/1.0", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 );
|
||||
|
||||
if ( !internet_session )
|
||||
return nlohmann::json::parse( response_data );
|
||||
return { nlohmann::json::parse( response_data ), true };
|
||||
|
||||
auto http_session = InternetConnectA( internet_session, domain, 80, 0, 0, INTERNET_SERVICE_HTTP, 0, NULL );
|
||||
|
||||
if ( !http_session )
|
||||
return nlohmann::json::parse( response_data );
|
||||
return { nlohmann::json::parse( response_data ), true };
|
||||
|
||||
HINTERNET http_req = HttpOpenRequestA( http_session, "GET", url, 0, 0, 0, INTERNET_FLAG_RELOAD, 0 );
|
||||
|
||||
@ -24,7 +24,7 @@ namespace util {
|
||||
const char* szHeaders = "Content-Type: application/json\r\nUser-Agent: Unspotify/1.0";
|
||||
|
||||
if ( !HttpSendRequestA( http_req, szHeaders, strlen( szHeaders ), NULL, NULL ) )
|
||||
return response_data;
|
||||
return { response_data, true };
|
||||
|
||||
response_data.clear( );
|
||||
|
||||
@ -39,9 +39,9 @@ namespace util {
|
||||
InternetCloseHandle( internet_session );
|
||||
|
||||
try {
|
||||
return nlohmann::json::parse( response_data );
|
||||
return { nlohmann::json::parse( response_data ), false };
|
||||
} catch ( const nlohmann::json::parse_error& er ) {
|
||||
return nlohmann::json::parse( err_json_data );
|
||||
return { nlohmann::json::parse( err_json_data ), true };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <Windows.h>
|
||||
#include <urlmon.h>
|
||||
#include <WinInet.h>
|
||||
#include <map>
|
||||
|
||||
#include "ext/json.hpp"
|
||||
|
||||
@ -11,8 +12,9 @@
|
||||
|
||||
namespace util {
|
||||
namespace networking {
|
||||
using errorable_json_result = std::pair<nlohmann::json, bool>;
|
||||
constexpr const char* err_json_data = "{\"error\": \"Unable to connect to server\"}";
|
||||
|
||||
nlohmann::json get( const char* domain, const char* url );
|
||||
errorable_json_result get( const char* domain, const char* url );
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user