From fa7be4520b0681da5d84fe6031d1bbfb7f1735c8 Mon Sep 17 00:00:00 2001 From: "jihye424.kim" Date: Wed, 16 Sep 2015 09:54:37 +0900 Subject: [PATCH] Build: delete the redundant file - delete 'emulator-manager.c' Change-Id: Ie533b13d862dc60954a6a09072d13db0e62bd52b Signed-off-by: jihye424.kim --- supplement/emulator-manager.c | 217 ------------------------------------------ 1 file changed, 217 deletions(-) delete mode 100644 supplement/emulator-manager.c diff --git a/supplement/emulator-manager.c b/supplement/emulator-manager.c deleted file mode 100644 index ec88797..0000000 --- a/supplement/emulator-manager.c +++ /dev/null @@ -1,217 +0,0 @@ -#define MAX 2048 -#define BUFSIZE 4096 -#define EMULMGR_JAR "\\emulator-manager.jar" -#include -#include -#include - -// for 64bit windows -#define MY_KEY_WOW64_64KEY 0x0100 - -HANDLE g_hChildStd_OUT_Rd = NULL; -HANDLE g_hChildStd_OUT_Wr = NULL; - -DWORD WINAPI OutputFunction( LPVOID lpParam ) -{ - DWORD dwRead, dwWritten; - CHAR chBuf[BUFSIZE]; - BOOL bSuccess = FALSE; - //HANDLE hParentStdOut = GetStdHandle(STD_OUTPUT_HANDLE); - - for (;;) - { - memset(chBuf, 0, BUFSIZE); - bSuccess = ReadFile( g_hChildStd_OUT_Rd, chBuf, BUFSIZE, &dwRead, NULL); - if( ! bSuccess || dwRead == 0 ) break; - - fprintf(stdout, "%s", chBuf); - if (! bSuccess ) break; - } - - return 0; -} - -typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); - -LPFN_ISWOW64PROCESS fnIsWow64Process; - -BOOL IsWow64() -{ - BOOL bIsWow64 = FALSE; - - //IsWow64Process is not available on all supported versions of Windows. - //Use GetModuleHandle to get a handle to the DLL that contains the function - //and GetProcAddress to get a pointer to the function if available. - - fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress( - GetModuleHandle(TEXT("kernel32")),"IsWow64Process"); - - if(NULL != fnIsWow64Process) - { - if (!fnIsWow64Process(GetCurrentProcess(),&bIsWow64)) - { - //handle error - } - } - return bIsWow64; -} - -int getJavaPath(char** java_path) -{ - HKEY hKeyNew; - HKEY hKey; - char strJavaRuntimePath[MAX] = {0}; - char strChoosenName[MAX] = {0}; - char strSubKeyName[MAX] = {0}; - char strJavaHome[MAX] = {0}; - int index; - DWORD dwSubKeyNameMax = MAX; - DWORD dwBufLen = MAX; - - RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\JavaSoft\\Java Runtime Environment", 0, - KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | MY_KEY_WOW64_64KEY , &hKey); - RegEnumKeyEx(hKey, 0, (LPSTR)strSubKeyName, &dwSubKeyNameMax, NULL, NULL, NULL, NULL); - strcpy(strChoosenName, strSubKeyName); - - index = 1; - while (ERROR_SUCCESS == RegEnumKeyEx(hKey, index, (LPSTR)strSubKeyName, &dwSubKeyNameMax, - NULL, NULL, NULL, NULL)) { - if (strcmp(strChoosenName, strSubKeyName) < 0) { - strcpy(strChoosenName, strSubKeyName); - } - index++; - } - - RegOpenKeyEx(hKey, strChoosenName, 0, KEY_QUERY_VALUE | MY_KEY_WOW64_64KEY, &hKeyNew); - RegQueryValueEx(hKeyNew, "JavaHome", NULL, NULL, (LPBYTE)strJavaHome, &dwBufLen); - RegCloseKey(hKey); - if (strJavaHome[0] != '\0') { - sprintf(*java_path, "\"%s\\bin\\javaw\" -jar ", strJavaHome); - //strcpy(*java_path, strJavaHome); - //strcat(*java_path, "\\bin\\javaw -jar "); - } else { - return 0; - } - return 1; -} - -int main(int argc, char* argv[]) -{ - char strCommand[BUFSIZE]; - - char strInstalledPath[MAX]; - char currentEmulmgr[MAX]; - DWORD ret; - int i; - DWORD fileAttr; - STARTUPINFO sti = { 0 }; - PROCESS_INFORMATION pi = { 0 }; - HANDLE hThread; - DWORD dwBufLen = MAX; - - ret = GetCurrentDirectory(512, currentEmulmgr); - strcat(currentEmulmgr, EMULMGR_JAR); - - // find location of emulator-manager.exe file - GetModuleFileName(0, strInstalledPath, MAX); - //printf("===> (%s)\n", strInstalledPath); - - - // make a command that start emulator-manager - if (IsWow64()) { - //printf("isWow64Process\n"); - char* strJavaPath = malloc(MAX); - if (getJavaPath(&strJavaPath)) { - strcpy(strCommand, strJavaPath); - } else { - strcpy(strCommand, "javaw -jar "); - } - free(strJavaPath); - } else { - strcpy(strCommand, "javaw -jar "); - } - - fileAttr = GetFileAttributes(currentEmulmgr); - if (0xFFFFFFFF == fileAttr) { - if (strInstalledPath == 0) { - fprintf(stderr, "Can not find path of tizen ide installed"); - exit(1); - } - strcat(strCommand, "\""); - strcat(strCommand, strInstalledPath); - strcat(strCommand, "\\..\\emulator-manager.jar\""); - } else { - strcat(strCommand, "\""); - strcat(strCommand, currentEmulmgr); - strcat(strCommand, "\""); - } - - /* - strcat(strCommand, " --vms \""); - strcat(strCommand, strLocalAppDataPath); - strcat(strCommand, "\""); - */ - - if(argc > 0) { - for(i = 1; i < argc; i++) { - strcat(strCommand, " "); - strcat(strCommand, argv[i]); - } - } - - // setting output redirect - SECURITY_ATTRIBUTES saAttr; - - // Set the bInheritHandle flag so pipe handles are inherited. - saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); - saAttr.bInheritHandle = TRUE; - saAttr.lpSecurityDescriptor = NULL; - - // Create a pipe for the child process's STDOUT. - if ( ! CreatePipe(&g_hChildStd_OUT_Rd, &g_hChildStd_OUT_Wr, &saAttr, 0) ) - { - fprintf(stderr,"StdoutRd CreatePipe"); - exit(1); - } - // Ensure the read handle to the pipe for STDOUT is not inherited. - if ( ! SetHandleInformation(g_hChildStd_OUT_Rd, HANDLE_FLAG_INHERIT, 0) ) - { - fprintf(stderr,"Stdout SetHandleInformation"); - exit(1); - } - - sti.cb = sizeof(STARTUPINFO); - sti.hStdError = g_hChildStd_OUT_Wr; - sti.hStdOutput = g_hChildStd_OUT_Wr; - sti.hStdInput = 0; - sti.dwFlags |= STARTF_USESTDHANDLES; - - //printf("strCommand = %s\n", strCommand); - if(!CreateProcess(NULL, - strCommand, - NULL, - NULL, - TRUE, - NORMAL_PRIORITY_CLASS, - NULL, - NULL, - &sti, - &pi) - ) { - fprintf(stderr, "Unable to generate Emulator Manager process\n"); - exit(1); - } - - { - DWORD dwThreadID; - hThread = CreateThread(0,0, OutputFunction, 0, 0, &dwThreadID); - } - - DWORD rc = WaitForSingleObject( - pi.hProcess, // process handle - INFINITE); - CloseHandle(pi.hProcess); - CloseHandle(pi.hThread); - CloseHandle(hThread); - return 0; -} -- 2.7.4