v1.0.5
- Add autoupdater
This commit is contained in:
parent
00ec4646ef
commit
a762348351
@ -8,7 +8,7 @@
|
|||||||
#define L_ERROR(...) util::logger::error(__FUNCTION__ "(): " __VA_ARGS__);
|
#define L_ERROR(...) util::logger::error(__FUNCTION__ "(): " __VA_ARGS__);
|
||||||
#define TRACE_FN util::logger::debug( "%s()", __FUNCTION__ );
|
#define TRACE_FN util::logger::debug( "%s()", __FUNCTION__ );
|
||||||
|
|
||||||
#define LOGGER_PARSE_FMT char buf[1024]; va_list va; va_start( va, fmt ); _vsnprintf_s( buf, 1024, fmt, va ); va_end( va );
|
#define LOGGER_PARSE_FMT char buf[2048]; va_list va; va_start( va, fmt ); _vsnprintf_s( buf, 1024, fmt, va ); va_end( va );
|
||||||
#define CREATE_LOGGER_METHOD(n) inline void n(const char* fmt, ...) { LOGGER_PARSE_FMT; log( #n, e_level_color::level_color_ ##n, buf ); }
|
#define CREATE_LOGGER_METHOD(n) inline void n(const char* fmt, ...) { LOGGER_PARSE_FMT; log( #n, e_level_color::level_color_ ##n, buf ); }
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "../util/util.h"
|
#include "../util/util.h"
|
||||||
#include "../spotify/spotify.h"
|
#include "../spotify/spotify.h"
|
||||||
#include "../hooks/hooks.h"
|
#include "../hooks/hooks.h"
|
||||||
|
#include "../updates/updates.h"
|
||||||
#include "shared/logo.h"
|
#include "shared/logo.h"
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
@ -11,6 +12,10 @@ namespace bootstrap {
|
|||||||
DWORD __stdcall _initial_routine( HANDLE ) {
|
DWORD __stdcall _initial_routine( HANDLE ) {
|
||||||
util::logo::create_console_and_draw_logo( );
|
util::logo::create_console_and_draw_logo( );
|
||||||
|
|
||||||
|
#ifdef CHECK_FOR_UPDATES
|
||||||
|
updates::do_job( );
|
||||||
|
#endif
|
||||||
|
|
||||||
spotify::init( );
|
spotify::init( );
|
||||||
hooks::init( );
|
hooks::init( );
|
||||||
|
|
||||||
|
13
spotify-reverse/defines.h
Normal file
13
spotify-reverse/defines.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// autoupdates
|
||||||
|
|
||||||
|
// @note: es3n1n: v1.0.5 = 105
|
||||||
|
#define UNSPOTIFY_VERSION 105
|
||||||
|
|
||||||
|
#define AUTOUPDATER_DOMAIN "es3n.in"
|
||||||
|
#define AUTOUPDATER_URL "unspotify.json"
|
||||||
|
|
||||||
|
#ifndef _DEBUG
|
||||||
|
#define CHECK_FOR_UPDATES
|
||||||
|
#endif
|
@ -186,6 +186,7 @@
|
|||||||
<ClCompile Include="hooks\hooked\create_track.cpp" />
|
<ClCompile Include="hooks\hooked\create_track.cpp" />
|
||||||
<ClCompile Include="hooks\hooks.cpp" />
|
<ClCompile Include="hooks\hooks.cpp" />
|
||||||
<ClCompile Include="spotify\spotify.cpp" />
|
<ClCompile Include="spotify\spotify.cpp" />
|
||||||
|
<ClCompile Include="updates\updates.cpp" />
|
||||||
<ClCompile Include="util\hooking\detours\detours.cpp" />
|
<ClCompile Include="util\hooking\detours\detours.cpp" />
|
||||||
<ClCompile Include="util\hooking\detours\mh\buffer.c" />
|
<ClCompile Include="util\hooking\detours\mh\buffer.c" />
|
||||||
<ClCompile Include="util\hooking\detours\mh\hde\hde32.c" />
|
<ClCompile Include="util\hooking\detours\mh\hde\hde32.c" />
|
||||||
@ -194,11 +195,13 @@
|
|||||||
<ClCompile Include="util\hooking\detours\mh\trampoline.c" />
|
<ClCompile Include="util\hooking\detours\mh\trampoline.c" />
|
||||||
<ClCompile Include="util\hooking\vmt\vmt.cpp" />
|
<ClCompile Include="util\hooking\vmt\vmt.cpp" />
|
||||||
<ClCompile Include="util\mem\module.h" />
|
<ClCompile Include="util\mem\module.h" />
|
||||||
|
<ClCompile Include="util\networking\networking.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="bootstrap\bootstrap.h" />
|
<ClInclude Include="bootstrap\bootstrap.h" />
|
||||||
<ClInclude Include="hooks\hooks.h" />
|
<ClInclude Include="hooks\hooks.h" />
|
||||||
<ClInclude Include="spotify\spotify.h" />
|
<ClInclude Include="spotify\spotify.h" />
|
||||||
|
<ClInclude Include="updates\updates.h" />
|
||||||
<ClInclude Include="util\hooking\detours\detours.h" />
|
<ClInclude Include="util\hooking\detours\detours.h" />
|
||||||
<ClInclude Include="util\hooking\detours\mh\buffer.h" />
|
<ClInclude Include="util\hooking\detours\mh\buffer.h" />
|
||||||
<ClInclude Include="util\hooking\detours\mh\hde\hde32.h" />
|
<ClInclude Include="util\hooking\detours\mh\hde\hde32.h" />
|
||||||
@ -211,6 +214,9 @@
|
|||||||
<ClInclude Include="util\hooking\hooking.h" />
|
<ClInclude Include="util\hooking\hooking.h" />
|
||||||
<ClInclude Include="util\hooking\vmt\vmt.h" />
|
<ClInclude Include="util\hooking\vmt\vmt.h" />
|
||||||
<ClInclude Include="util\mem\addr.h" />
|
<ClInclude Include="util\mem\addr.h" />
|
||||||
|
<ClInclude Include="defines.h" />
|
||||||
|
<ClInclude Include="util\networking\ext\json.hpp" />
|
||||||
|
<ClInclude Include="util\networking\networking.h" />
|
||||||
<ClInclude Include="util\util.h" />
|
<ClInclude Include="util\util.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
@ -60,6 +60,12 @@
|
|||||||
<ClCompile Include="hooks\hooked\create_track.cpp">
|
<ClCompile Include="hooks\hooked\create_track.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="util\networking\networking.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="updates\updates.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="util\util.h">
|
<ClInclude Include="util\util.h">
|
||||||
@ -110,5 +116,17 @@
|
|||||||
<ClInclude Include="hooks\hooks.h">
|
<ClInclude Include="hooks\hooks.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="util\networking\networking.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="util\networking\ext\json.hpp">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="defines.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="updates\updates.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
46
spotify-reverse/updates/updates.cpp
Normal file
46
spotify-reverse/updates/updates.cpp
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#include "updates.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace updates {
|
||||||
|
update_info_t poll_info( ) {
|
||||||
|
auto data = util::networking::get( AUTOUPDATER_DOMAIN, AUTOUPDATER_URL );
|
||||||
|
if ( data.find( "error" ) != data.end( ) )
|
||||||
|
return update_info_t {
|
||||||
|
.m_error = true,
|
||||||
|
.m_error_desc = data[ "error" ].get<std::string>( )
|
||||||
|
};
|
||||||
|
|
||||||
|
return update_info_t {
|
||||||
|
.m_error = false,
|
||||||
|
.m_version = data[ "version" ].get<uint32_t>( ),
|
||||||
|
.m_changelog = data[ "changelog" ].get<std::string>( ),
|
||||||
|
.m_is_required = data[ "required" ].get<bool>( ),
|
||||||
|
.m_download_url = data[ "download_url" ].get<std::string>( )
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void do_job( ) {
|
||||||
|
auto update_info = poll_info( );
|
||||||
|
if ( update_info.m_error ) {
|
||||||
|
util::logger::error( "Failed to poll newest version info: %s", update_info.m_error_desc.c_str( ) );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( update_info.m_version <= UNSPOTIFY_VERSION ) // @note: es3n1n: if we are up2date
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( update_info.m_is_required ) {
|
||||||
|
util::logger::fatal( "New version is available!\n\nChangelog:\n%s\nDownload url: %s", update_info.m_changelog.c_str( ), update_info.m_download_url.c_str( ) );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
util::logger::info( "New version is available!" );
|
||||||
|
util::logger::info( "" );
|
||||||
|
util::logger::info( "" );
|
||||||
|
util::logger::info( "Changelog:" );
|
||||||
|
printf( "%s\n", update_info.m_changelog.c_str( ) );
|
||||||
|
util::logger::info( "" );
|
||||||
|
util::logger::info( "" );
|
||||||
|
util::logger::info( "Download url: %s", update_info.m_download_url.c_str( ) );
|
||||||
|
}
|
||||||
|
}
|
20
spotify-reverse/updates/updates.h
Normal file
20
spotify-reverse/updates/updates.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "../defines.h"
|
||||||
|
#include "../util/networking/networking.h"
|
||||||
|
#include "shared/logger.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace updates {
|
||||||
|
struct update_info_t {
|
||||||
|
bool m_error = false;
|
||||||
|
std::string m_error_desc = "Unable to connect to server";
|
||||||
|
|
||||||
|
uint32_t m_version = UNSPOTIFY_VERSION;
|
||||||
|
std::string m_changelog = "Failed to request update info";
|
||||||
|
bool m_is_required = false;
|
||||||
|
std::string m_download_url = "https://git.tcp.direct/dg/unspotify";
|
||||||
|
};
|
||||||
|
|
||||||
|
update_info_t poll_info( );
|
||||||
|
void do_job( );
|
||||||
|
}
|
22091
spotify-reverse/util/networking/ext/json.hpp
Normal file
22091
spotify-reverse/util/networking/ext/json.hpp
Normal file
File diff suppressed because it is too large
Load Diff
40
spotify-reverse/util/networking/networking.cpp
Normal file
40
spotify-reverse/util/networking/networking.cpp
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
#include "networking.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace util {
|
||||||
|
namespace networking {
|
||||||
|
nlohmann::json get( const char* domain, const char* url ) {
|
||||||
|
std::string response_data = "{\"error\": \"Unable to connect to server\"}";
|
||||||
|
|
||||||
|
auto internet_session = InternetOpenA( "", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 );
|
||||||
|
|
||||||
|
if ( !internet_session ) return nlohmann::json::parse( response_data );
|
||||||
|
|
||||||
|
auto http_session = InternetConnectA( internet_session, domain, 80, 0, 0, INTERNET_SERVICE_HTTP, 0, NULL );
|
||||||
|
|
||||||
|
if ( !http_session ) return nlohmann::json::parse( response_data );
|
||||||
|
|
||||||
|
HINTERNET http_req = HttpOpenRequestA( http_session, "GET", url, 0, 0, 0, INTERNET_FLAG_RELOAD, 0 );
|
||||||
|
|
||||||
|
if ( !http_session ) return nlohmann::json::parse( response_data );
|
||||||
|
|
||||||
|
const char* szHeaders = "Content-Type: text/html\r\nUser-Agent: Unspotify/1.0";
|
||||||
|
|
||||||
|
if ( !HttpSendRequestA( http_req, szHeaders, strlen( szHeaders ), NULL, NULL ) ) return response_data;
|
||||||
|
|
||||||
|
response_data.clear( );
|
||||||
|
|
||||||
|
CHAR temp_buffer[ 1024 ] = { 0 };
|
||||||
|
DWORD read_ret = 0;
|
||||||
|
|
||||||
|
while ( InternetReadFile( http_req, temp_buffer, sizeof( temp_buffer ) - 1, &read_ret ) && read_ret )
|
||||||
|
response_data.append( temp_buffer, read_ret );
|
||||||
|
|
||||||
|
InternetCloseHandle( http_req );
|
||||||
|
InternetCloseHandle( http_session );
|
||||||
|
InternetCloseHandle( internet_session );
|
||||||
|
|
||||||
|
return nlohmann::json::parse( response_data );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
16
spotify-reverse/util/networking/networking.h
Normal file
16
spotify-reverse/util/networking/networking.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <Windows.h>
|
||||||
|
#include <urlmon.h>
|
||||||
|
#include <WinInet.h>
|
||||||
|
|
||||||
|
#include "ext/json.hpp"
|
||||||
|
|
||||||
|
#pragma comment(lib, "urlmon.lib")
|
||||||
|
#pragma comment(lib, "wininet.lib")
|
||||||
|
|
||||||
|
|
||||||
|
namespace util {
|
||||||
|
namespace networking {
|
||||||
|
nlohmann::json get( const char* domain, const char* url );
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user