forked from ukatech/generic_ghost_installer
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ecee3a4
commit 23aad83
Showing
5 changed files
with
89 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"files.associations": { | ||
"xstring": "cpp" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include <string> | ||
#include <windows.h> | ||
std::wstring download_temp_file(const std::wstring& url, const std::wstring& file_suffix) { | ||
//get temp path | ||
static wchar_t temp_path[MAX_PATH]; | ||
static bool temp_path_initer=(bool)GetTempPath(MAX_PATH, temp_path); | ||
//generate a temporary file name | ||
std::wstring temp_file_name; | ||
temp_file_name.reserve(MAX_PATH); | ||
GetTempFileNameW(temp_path, L"ghi", 0, temp_file_name.data()); | ||
temp_file_name.resize(wcslen(temp_file_name.data())); | ||
//append file suffix | ||
temp_file_name+=file_suffix; | ||
//download file | ||
HINTERNET hInternet=InternetOpenW(L"ghost_installer", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); | ||
if(hInternet==NULL) { | ||
throw std::runtime_error("InternetOpenW failed"); | ||
} | ||
HINTERNET hFile=InternetOpenUrlW(hInternet, url.c_str(), NULL, 0, INTERNET_FLAG_NO_CACHE_WRITE, 0); | ||
if(hFile==NULL) { | ||
InternetCloseHandle(hInternet); | ||
throw std::runtime_error("InternetOpenUrlW failed"); | ||
} | ||
HANDLE hFileHandle=CreateFileW(temp_file_name.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); | ||
if(hFileHandle==INVALID_HANDLE_VALUE) { | ||
InternetCloseHandle(hFile); | ||
InternetCloseHandle(hInternet); | ||
throw std::runtime_error("CreateFileW failed"); | ||
} | ||
DWORD dwBytesRead=0; | ||
DWORD dwBytesWritten=0; | ||
unsigned char buffer[1024]; | ||
while(InternetReadFile(hFile, buffer, 1024, &dwBytesRead) && dwBytesRead>0) { | ||
WriteFile(hFileHandle, buffer, dwBytesRead, &dwBytesWritten, NULL); | ||
} | ||
InternetCloseHandle(hFile); | ||
InternetCloseHandle(hInternet); | ||
CloseHandle(hFileHandle); | ||
return temp_file_name; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include <windows.h> | ||
#include <shlobj_core.h> | ||
#include "my-gists/ukagaka/SSP_Runner.hpp" | ||
|
||
std::wstring download_temp_file(const std::wstring& url, const std::wstring& file_suffix); | ||
std::wstring get_ghost_url(){ | ||
#ifdef _DEBUG | ||
return L"https://github.com/Taromati2/Taromati2/releases/download/balloon/wiz.nar"; | ||
#else | ||
//TODO get ghost url from self file | ||
#endif | ||
} | ||
|
||
int main() { | ||
SSP_Runner SSP; | ||
if(SSP.IsInstalled()) { | ||
try{ | ||
auto nar_file=download_temp_file(get_ghost_url(), L".nar"); | ||
SSP.install_nar(nar_file); | ||
} | ||
catch(const std::exception& e) { | ||
MessageBoxA(NULL, e.what(), "Error", MB_OK); | ||
} | ||
} | ||
else{ | ||
//download and install SSP | ||
auto ssp_file=download_temp_file(L"http://ssp.shillest.net/archive/redir.cgi?stable&full", L".exe"); | ||
EXE_Runner SSP_EXE(ssp_file); | ||
//Get the program (x86) directory for installation | ||
std::wstring program_dir; | ||
program_dir.reserve(MAX_PATH); | ||
SHGetSpecialFolderPath(NULL, program_dir.data(), CSIDL_PROGRAM_FILESX86, FALSE); | ||
program_dir.resize(wcslen(program_dir.data())); | ||
program_dir+=L"\\SSP"; | ||
SSP_EXE(L"-o\""+program_dir+L"\""); | ||
//get language id | ||
//show install path dialog | ||
//install SSP(download zip & extract) | ||
//chose&install language pack & ghost for starter | ||
//install ghost | ||
} | ||
return 0; | ||
} |
Submodule my-gists
updated
12 files
+1 −0 | STL/replace_all.cpp | |
+1 −0 | STL/replace_all.hpp | |
+145 −0 | ukagaka/SFMO.cpp | |
+7 −101 | ukagaka/SFMO.hpp | |
+9 −0 | ukagaka/SSP_Runner.cpp | |
+40 −0 | ukagaka/SSP_Runner.hpp | |
+3 −4 | ukagaka/SSPpath.cpp | |
+2 −1 | ukagaka/SSPpath.hpp | |
+11 −0 | windows/CMDargsConverter.cpp | |
+3 −0 | windows/CMDargsConverter.hpp | |
+8 −0 | windows/EXE_Runner.cpp | |
+32 −0 | windows/EXE_Runner.hpp |