-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- shmake now includes shim as a resource for self-containment
- Loading branch information
Showing
16 changed files
with
299 additions
and
40 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
Binary file not shown.
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 |
---|---|---|
@@ -1,19 +1,70 @@ | ||
#include <iostream> | ||
#include <string> | ||
#include "windows.h" | ||
#include "resource.h" | ||
#include "../shmake/resources.h" | ||
#include "../shmake/util.h" | ||
|
||
using namespace std; | ||
|
||
#define MAX_LOADSTRING 1024 | ||
const wstring CMD_TOKEN = L"%s"; | ||
|
||
int main(int argc, char* argv) | ||
int wmain(int argc, wchar_t* argv[]) | ||
{ | ||
resources res; | ||
auto cmd_pattern = res.load_string(IDS_TARGET_CMDLINE); | ||
|
||
auto cmdline = res.load_string(IDS_TARGET_CMDLINE); | ||
wcout << "cmdline: " << cmd_pattern << endl; | ||
|
||
wcout << "cmdline: " << cmdline << endl; | ||
wstring cmd = cmd_pattern; | ||
|
||
return 0; | ||
if (argc > 1) | ||
{ | ||
size_t pos = cmd.find(CMD_TOKEN); | ||
if (pos != string::npos) | ||
{ | ||
cmd.replace(pos, CMD_TOKEN.size(), argv[1]); | ||
} | ||
} | ||
|
||
wcout << "final: " << cmd << endl; | ||
|
||
STARTUPINFO si; | ||
PROCESS_INFORMATION pi; | ||
|
||
::ZeroMemory(&si, sizeof(si)); | ||
si.cb = sizeof(si); | ||
|
||
::ZeroMemory(&pi, sizeof(pi)); | ||
|
||
if(!::CreateProcess( | ||
NULL, // lpApplicationName | ||
const_cast<LPWSTR>(cmd.c_str()), | ||
NULL, // lpProcessAttributes | ||
NULL, // lpThreadAttributes | ||
TRUE, // bInheritHandles | ||
NULL, // dwCreationFlags | ||
NULL, // lpEnvironment | ||
NULL, // lpCurrentDirectory | ||
&si, | ||
&pi)) | ||
{ | ||
wstring emsg = get_win32_last_error(); | ||
wcout << L"failed: " << emsg; | ||
return 1; | ||
} | ||
|
||
wcout << L"waiting... "; | ||
::WaitForSingleObject(pi.hProcess, INFINITE); | ||
wcout << L"done." << endl; | ||
|
||
DWORD exit_code = 0; | ||
// if next line fails, code is still 0 | ||
::GetExitCodeProcess(pi.hProcess, &exit_code); | ||
|
||
// free OS resources | ||
::CloseHandle(pi.hProcess); | ||
::CloseHandle(pi.hThread); | ||
|
||
return exit_code; | ||
} |
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
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
Binary file not shown.
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,69 @@ | ||
// Microsoft Visual C++ generated resource script. | ||
// | ||
#include "resource.h" | ||
|
||
#define APSTUDIO_READONLY_SYMBOLS | ||
///////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Generated from the TEXTINCLUDE 2 resource. | ||
// | ||
#include "winres.h" | ||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
#undef APSTUDIO_READONLY_SYMBOLS | ||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
// English (United Kingdom) resources | ||
|
||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG) | ||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK | ||
#pragma code_page(1252) | ||
|
||
#ifdef APSTUDIO_INVOKED | ||
///////////////////////////////////////////////////////////////////////////// | ||
// | ||
// TEXTINCLUDE | ||
// | ||
|
||
1 TEXTINCLUDE | ||
BEGIN | ||
"resource.h\0" | ||
END | ||
|
||
2 TEXTINCLUDE | ||
BEGIN | ||
"#include ""winres.h""\r\n" | ||
"\0" | ||
END | ||
|
||
3 TEXTINCLUDE | ||
BEGIN | ||
"\r\n" | ||
"\0" | ||
END | ||
|
||
#endif // APSTUDIO_INVOKED | ||
|
||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
// | ||
// RCDATA | ||
// | ||
|
||
IDR_SHIM_EXE RCDATA "shim.bin" | ||
|
||
#endif // English (United Kingdom) resources | ||
///////////////////////////////////////////////////////////////////////////// | ||
|
||
|
||
|
||
#ifndef APSTUDIO_INVOKED | ||
///////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Generated from the TEXTINCLUDE 3 resource. | ||
// | ||
|
||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
#endif // not APSTUDIO_INVOKED | ||
|
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,16 @@ | ||
//{{NO_DEPENDENCIES}} | ||
// Microsoft Visual C++ generated include file. | ||
// Used by data.rc | ||
// | ||
#define IDR_SHIM_EXE 102 | ||
|
||
// Next default values for new objects | ||
// | ||
#ifdef APSTUDIO_INVOKED | ||
#ifndef APSTUDIO_READONLY_SYMBOLS | ||
#define _APS_NEXT_RESOURCE_VALUE 103 | ||
#define _APS_NEXT_COMMAND_VALUE 40001 | ||
#define _APS_NEXT_CONTROL_VALUE 1001 | ||
#define _APS_NEXT_SYMED_VALUE 101 | ||
#endif | ||
#endif |
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
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
Binary file not shown.
Oops, something went wrong.