// create the child process with command line "-runas session -parent [parent process id]" // the child process will run in the specified session HANDLE CWinRobotService::CreateChildProcess(ULONG sid) { TrackDebugOut; WCHAR szComd[MAX_PATH*2]; WCHAR curpath[MAX_PATH]; GetModuleFileNameW( 0, curpath, MAX_PATH ); PathRemoveFileSpec(curpath); DWORD dwProcessId = 0; HANDLE hNewToken = NULL; HRESULT hr = S_OK; HWINSTA hwinsta = NULL; HANDLE hToken= NULL; void* pEnvBlock = NULL; PROCESS_INFORMATION pi; ZeroMemory(&pi,sizeof(pi)); DWORD errcode=0; try { DebugOutF(filelog::log_info,"attempt to CreateChildProcess %d",sid); // HANDLE hCurProcess = 0; // // DuplicateHandle(GetCurrentProcess(),GetCurrentProcess(), GetCurrentProcess(), &hCurProcess, // 0, TRUE, DUPLICATE_SAME_ACCESS); #ifdef _WIN64 swprintf(szComd,L"\"%s\\WinRobotHostx64.exe\" -runas session -parent %d",curpath,GetProcessId(GetCurrentProcess())); #else swprintf(szComd,L"\"%s\\WinRobotHostx86.exe\" -runas session -parent %d",curpath,GetProcessId(GetCurrentProcess())); #endif STARTUPINFOW si; ZeroMemory(&si, sizeof(STARTUPINFOW)); si.cb= sizeof(STARTUPINFOW); DWORD dwCreationFlags = NORMAL_PRIORITY_CLASS; si.lpDesktop = L"winsta0\\default";; INT *pState = NULL; DWORD buflen = 0; ConnectActiveSession(); if(!OpenProcessToken(GetCurrentProcess(),TOKEN_ALL_ACCESS,&hToken)){ DebugOutF(filelog::log_error,"OpenProcessToken failed , error code = %d",GetLastError()); throw E_UNEXPECTED; } // Duplicate the token because we need modify it if(!DuplicateTokenEx(hToken,MAXIMUM_ALLOWED,0,SecurityAnonymous ,TokenPrimary ,&hNewToken)){ errcode = GetLastError(); DebugOutF(filelog::log_error,"DuplicateTokenEx failed , error code = %d",GetLastError()); throw HRESULT_FROM_WIN32(errcode); } // change the token so that the process will be create in the new session if(!SetTokenInformation(hNewToken,TokenSessionId,&sid,sizeof(DWORD))) { errcode = GetLastError(); DebugOutF(filelog::log_error,"SetTokenInformation failed , error code = %d",GetLastError()); throw HRESULT_FROM_WIN32(errcode); } if(!CreateEnvironmentBlock( &pEnvBlock, hToken, TRUE)){ DebugOutF(filelog::log_error,"CreateEnvironmentBlock Failed, error code = %d",GetLastError()); }else{ dwCreationFlags |= CREATE_UNICODE_ENVIRONMENT; } BOOL bCreate = FALSE; for(int i=0;i<5;i++) { if(!(bCreate = CreateProcessAsUserW(hNewToken, 0,szComd,0,0,FALSE,dwCreationFlags ,pEnvBlock,curpath,&si,&pi ))) { if(GetLastError() == 233){ // change the token so that the process will be create in the new session sid = 0; if(!SetTokenInformation(hNewToken,TokenSessionId,&sid,sizeof(DWORD))) { errcode = GetLastError(); DebugOutF(filelog::log_error,"SetTokenInformation failed , error code = %d",GetLastError()); throw HRESULT_FROM_WIN32(errcode); } continue; } Sleep(300); continue; } else { break; } } if(bCreate) { DebugOutF(filelog::log_info,"CreateChildProcess on session %d ok",sid); } else { DebugOutF(filelog::log_error,"CreateProcessAsUser on session %d %s,%s,failed error code = %d" ,sid,(char*)CW2A(szComd),(char*)CW2A(curpath),GetLastError()); } } catch (HRESULT hr1) { hr = hr1; } if(hToken) CloseHandle(hToken); if(hNewToken)CloseHandle(hNewToken); if(pi.hThread){CloseHandle(pi.hThread);pi.hThread = 0;} if(pEnvBlock)DestroyEnvironmentBlock(pEnvBlock); return pi.hProcess; }
bool AOLayer::Initialize(ITable* pTable) { HRESULT hr; m_ipTable = pTable; CComBSTR temp; IDatasetPtr ipDataset = m_ipTable; if (FAILED(hr = ipDataset->get_Name(&temp))) return false; m_pFeatureDefn = new OGRFeatureDefn(CW2A(temp)); //Should I "new" an OGR smart pointer - sample says so, but it doesn't seem right //as long as we use the same compiler & settings in both the ogr build and this //driver, we should be OK m_pFeatureDefn->Reference(); IFeatureClassPtr ipFC = m_ipTable; VARIANT_BOOL hasOID = VARIANT_FALSE; ipFC->get_HasOID(&hasOID); if (hasOID == VARIANT_TRUE) { ipFC->get_OIDFieldName(&temp); m_strOIDFieldName = CW2A(temp); } if (FAILED(hr = ipFC->get_ShapeFieldName(&temp))) return AOErr(hr, "No shape field found!"); m_strShapeFieldName = CW2A(temp); IFieldsPtr ipFields; if (FAILED(hr = ipFC->get_Fields(&ipFields))) return AOErr(hr, "Fields not found!"); long shapeIndex = -1; if (FAILED(hr = ipFields->FindField(temp, &shapeIndex))) return AOErr(hr, "Shape field not found!"); IFieldPtr ipShapeField; if (FAILED(hr = ipFields->get_Field(shapeIndex, &ipShapeField))) return false; // Use GeometryDef to set OGR shapetype and Spatial Reference information // IGeometryDefPtr ipGeoDef; if (FAILED(hr = ipShapeField->get_GeometryDef(&ipGeoDef))) return false; OGRwkbGeometryType ogrGeoType; if (!AOToOGRGeometry(ipGeoDef, &ogrGeoType)) return false; m_pFeatureDefn->SetGeomType(ogrGeoType); if (wkbFlatten(ogrGeoType) == wkbMultiLineString || wkbFlatten(ogrGeoType) == wkbMultiPoint) m_forceMulti = true; // Mapping of Spatial Reference will be passive about errors // (it is possible we won't be able to map some ESRI-specific projections) esriGeometry::ISpatialReferencePtr ipSR = NULL; if (FAILED(hr = ipGeoDef->get_SpatialReference(&ipSR))) { AOErr(hr, "Failed Fetching ESRI spatial reference"); } else { if (!AOToOGRSpatialReference(ipSR, &m_pSRS)) { //report error, but be passive about it CPLError( CE_Warning, CPLE_AppDefined, "Failed Mapping ESRI Spatial Reference"); } } // Map fields // return AOToOGRFields(ipFields, m_pFeatureDefn, m_OGRFieldToESRIField); }
bool AOLayer::OGRFeatureFromAORow(IRow* pRow, OGRFeature** ppFeature) { HRESULT hr; OGRFeature* pOutFeature = new OGRFeature(m_pFeatureDefn); ///////////////////////////////////////////////////////// // Translate OID // long oid = -1; if (FAILED(hr = pRow->get_OID(&oid))) { //this should never happen delete pOutFeature; return false; } pOutFeature->SetFID(oid); ///////////////////////////////////////////////////////// // Translate Geometry // IFeaturePtr ipFeature = pRow; esriGeometry::IGeometryPtr ipGeometry = NULL; if (FAILED(hr = ipFeature->get_Shape(&ipGeometry)) || ipGeometry == NULL) { delete pOutFeature; return AOErr(hr, "Failed retrieving shape from ArcObjects"); } OGRGeometry* pOGRGeo = NULL; if ((!AOGeometryToOGRGeometry(m_forceMulti, ipGeometry, m_pSRS, m_pBuffer, m_bufferSize, &pOGRGeo)) || pOGRGeo == NULL) { delete pOutFeature; return AOErr(hr, "Failed to translate ArcObjects Geometry to OGR Geometry"); } pOutFeature->SetGeometryDirectly(pOGRGeo); ////////////////////////////////////////////////////////// // Map fields // CComVariant val; size_t mappedFieldCount = m_OGRFieldToESRIField.size(); bool foundBadColumn = false; for (size_t i = 0; i < mappedFieldCount; ++i) { long index = m_OGRFieldToESRIField[i]; if (FAILED(hr = pRow->get_Value(index, &val))) { // this should not happen return AOErr(hr, "Failed retrieving row value"); } if (val.vt == VT_NULL) { continue; //leave as unset } // // NOTE: This switch statement needs to be kept in sync with AOToOGRGeometry // since we are only checking for types we mapped in that utility function switch (m_pFeatureDefn->GetFieldDefn(i)->GetType()) { case OFTInteger: { val.ChangeType(VT_I4); pOutFeature->SetField(i, val.intVal); } break; case OFTReal: { val.ChangeType(VT_R8); pOutFeature->SetField(i, val.dblVal); } break; case OFTString: { val.ChangeType(VT_BSTR); pOutFeature->SetField(i, CW2A(val.bstrVal)); } break; /* TODO: Need to get test dataset to implement these leave it as NULL for now case OFTBinary: { // Access as SafeArray with SafeArrayAccessData perhaps? } break; case OFTDateTime: { // Examine test data to figure out how to extract that } break; */ default: { if (!m_supressColumnMappingError) { foundBadColumn = true; CPLError( CE_Warning, CPLE_AppDefined, "Row id: %d col:%d has unhandled col type (%d). Setting to NULL.", oid, i, m_pFeatureDefn->GetFieldDefn(i)->GetType()); } } } } if (foundBadColumn) m_supressColumnMappingError = true; *ppFeature = pOutFeature; return true; }
int ScriptWrapper::ConvertResultToJsonValue(BrowserManager *manager, Json::Value *value) { int status_code = SUCCESS; if (this->ResultIsString()) { std::string string_value; string_value = CW2A(this->result_.bstrVal, CP_UTF8); *value = string_value; } else if (this->ResultIsInteger()) { *value = this->result_.lVal; } else if (this->ResultIsDouble()) { *value = this->result_.dblVal; } else if (this->ResultIsBoolean()) { *value = this->result_.boolVal == VARIANT_TRUE; } else if (this->ResultIsEmpty()) { *value = Json::Value::null; } else if (this->ResultIsIDispatch()) { if (this->ResultIsArray() || this->ResultIsElementCollection()) { Json::Value result_array(Json::arrayValue); long length = 0; status_code = this->GetArrayLength(&length); for (long i = 0; i < length; ++i) { Json::Value array_item_result; int array_item_status = this->GetArrayItem(manager, i, &array_item_result); result_array[i] = array_item_result; } *value = result_array; } else if (this->ResultIsObject()) { Json::Value result_object; std::wstring property_name_list(L""); status_code = this->GetPropertyNameList(&property_name_list); std::vector<std::wstring> property_names; size_t end_position(0); size_t start_position(0); while (true) { std::wstring property_name(L""); end_position = property_name_list.find_first_of(L",", start_position); if(end_position == std::wstring::npos) { property_names.push_back(property_name_list.substr(start_position, property_name_list.size() - start_position)); break; } else { property_names.push_back(property_name_list.substr(start_position, end_position - start_position)); start_position = end_position + 1; } } for (size_t i = 0; i < property_names.size(); ++i) { Json::Value property_value_result; int property_value_status = this->GetPropertyValue(manager, property_names[i], &property_value_result); std::string name(CW2A(property_names[i].c_str(), CP_UTF8)); result_object[name] = property_value_result; } *value = result_object; } else { IHTMLElement *node = (IHTMLElement*) this->result_.pdispVal; std::tr1::shared_ptr<ElementWrapper> element_wrapper; manager->AddManagedElement(node, &element_wrapper); *value = element_wrapper->ConvertToJson(); } } else { status_code = EUNKNOWNSCRIPTRESULT; } return status_code; }
void CDialogProcSelect::ListRunningProcs( ) { if (m_bLoadingProcesses) return; m_ProcessIcons.DeleteImageList( ); m_ProcessIcons.Create( 15, 15, ILC_COLOR32, 1, 1 ); m_ProcessIcons.SetBkColor( RGB( 255, 255, 255 ) ); m_ProcessList.SetImageList( &m_ProcessIcons, LVSIL_SMALL ); m_ProcessList.DeleteAllItems( ); m_ProcessInfos.clear( ); PSYSTEM_PROCESS_INFORMATION ProcessInfo = NULL; std::unique_ptr<uint8_t[]> BufferArray; ULONG BufferSize = 0; NTSTATUS status; status = ntdll::NtQuerySystemInformation( SystemProcessInformation, NULL, NULL, &BufferSize ); if (status != STATUS_SUCCESS && status != STATUS_INFO_LENGTH_MISMATCH) { #ifdef _DEBUG PrintOut( _T( "[CDialogProcSelect::RefreshRunningProcesses] Failed to get size for system process list from ProcessBasicInformation" ) ); #endif return; } BufferArray = std::make_unique<uint8_t[]>( BufferSize + 1 ); if (NT_SUCCESS( ntdll::NtQuerySystemInformation( SystemProcessInformation, (PVOID)BufferArray.get( ), BufferSize, &BufferSize ) )) { int CurrentProcessIndex = 0; m_bLoadingProcesses = TRUE; ProcessInfo = (PSYSTEM_PROCESS_INFORMATION)BufferArray.get( ); while (ProcessInfo) { if (ProcessInfo->ImageName.Buffer && ProcessInfo->ImageName.Length > 0) { if (m_FilterCheck.GetCheck( ) != BST_CHECKED || CommonProcesses.end( ) == std::find_if( CommonProcesses.begin( ), CommonProcesses.end( ), [ProcessInfo] ( const wchar_t* proc ) { return _wcsnicmp( proc, ProcessInfo->ImageName.Buffer, ProcessInfo->ImageName.MaximumLength / sizeof(wchar_t) ) == 0; } ) ) { HANDLE hProcess = ReClassOpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, (DWORD)ProcessInfo->UniqueProcessId ); #ifdef _WIN64 if (hProcess && Utils::GetProcessPlatform( hProcess ) == Utils::ProcessPlatformX64) #else if (hProcess && Utils::GetProcessPlatform( hProcess ) == Utils::ProcessPlatformX86) #endif { ProcessInfoStack Info = { 0 }; TCHAR tcsProcessId[16] = { 0 }; TCHAR tcsProcessPath[MAX_PATH] = { 0 }; SHFILEINFO FileInfo = { 0 }; LVITEM lvi = { 0 }; int pos; Info.dwProcessId = (DWORD)ProcessInfo->UniqueProcessId; #ifdef UNICODE Info.strProcessName = ProcessInfo->ImageName.Buffer; #else Info.strProcessName = CW2A( ProcessInfo->ImageName.Buffer ); #endif GetModuleFileNameEx( hProcess, NULL, tcsProcessPath, MAX_PATH ); SHGetFileInfo( tcsProcessPath, NULL, &FileInfo, sizeof( SHFILEINFO ), SHGFI_ICON ); m_ProcessIcons.Add( FileInfo.hIcon ); lvi.mask = LVIF_TEXT | LVIF_IMAGE; lvi.pszText = Info.strProcessName.GetBuffer( ); lvi.cchTextMax = Info.strProcessName.GetLength( ); lvi.iImage = CurrentProcessIndex++; lvi.iItem = m_ProcessList.GetItemCount( ); pos = m_ProcessList.InsertItem( &lvi ); _ui64tot_s( Info.dwProcessId, tcsProcessId, 16, 10 ); m_ProcessList.SetItemText( pos, COLUMN_PROCESSID, (LPTSTR)tcsProcessId ); m_ProcessInfos.push_back( Info ); } CloseHandle( hProcess ); } } // Make sure not to loop infinitely (Fix for issue where refresh wasnt updating closed applications) if (ProcessInfo->NextEntryOffset == 0) break; ProcessInfo = (PSYSTEM_PROCESS_INFORMATION)((uint8_t*)ProcessInfo + ProcessInfo->NextEntryOffset); } } m_bLoadingProcesses = FALSE; }
DWORD BrowserFactory::LaunchBrowserProcess(const std::string& initial_url, const bool ignore_protected_mode_settings, std::string* error_message) { LOG(TRACE) << "Entering BrowserFactory::LaunchBrowserProcess"; DWORD process_id = NULL; bool has_valid_protected_mode_settings = false; LOG(DEBUG) << "Ignoring Protected Mode Settings: " << ignore_protected_mode_settings; if (!ignore_protected_mode_settings) { LOG(DEBUG) << "Checking validity of Protected Mode settings."; has_valid_protected_mode_settings = this->ProtectedModeSettingsAreValid(); } LOG(DEBUG) << "Has Valid Protected Mode Settings: " << has_valid_protected_mode_settings; if (ignore_protected_mode_settings || has_valid_protected_mode_settings) { STARTUPINFO start_info; PROCESS_INFORMATION proc_info; ::ZeroMemory(&start_info, sizeof(start_info)); start_info.cb = sizeof(start_info); ::ZeroMemory(&proc_info, sizeof(proc_info)); std::wstring wide_initial_url(CA2W(initial_url.c_str(), CP_UTF8)); FARPROC proc_address = 0; HMODULE library_handle = ::LoadLibrary(IEFRAME_LIBRARY_NAME); if (library_handle != NULL) { proc_address = ::GetProcAddress(library_handle, IELAUNCHURL_FUNCTION_NAME); } std::string launch_api = "The IELaunchURL() API"; std::string launch_error = ""; if (proc_address != 0) { // If we have the IELaunchURL API, expressly use it. This will // guarantee a new session. Simply using CoCreateInstance to // create the browser will merge sessions, making separate cookie // handling impossible. HRESULT launch_result = ::IELaunchURL(wide_initial_url.c_str(), &proc_info, NULL); if (FAILED(launch_result)) { size_t launch_msg_count = _scprintf(IELAUNCHURL_ERROR_MESSAGE, launch_result, initial_url.c_str()); vector<char> launch_result_msg(launch_msg_count + 1); _snprintf_s(&launch_result_msg[0], sizeof(launch_result_msg), launch_msg_count + 1, IELAUNCHURL_ERROR_MESSAGE, launch_result, initial_url.c_str()); launch_error = &launch_result_msg[0]; *error_message = launch_error; } } else { launch_api = "The CreateProcess() API"; std::wstring executable_and_url = this->ie_executable_location_ + L" " + wide_initial_url; LPWSTR command_line = new WCHAR[executable_and_url.size() + 1]; wcscpy_s(command_line, executable_and_url.size() + 1, executable_and_url.c_str()); command_line[executable_and_url.size()] = L'\0'; BOOL create_process_result = ::CreateProcess(NULL, command_line, NULL, NULL, FALSE, 0, NULL, NULL, &start_info, &proc_info); if (!create_process_result) { int create_proc_msg_count = _scwprintf(CREATEPROCESS_ERROR_MESSAGE, command_line); vector<wchar_t> create_proc_result_msg(create_proc_msg_count + 1); _snwprintf_s(&create_proc_result_msg[0], sizeof(create_proc_result_msg), create_proc_msg_count, CREATEPROCESS_ERROR_MESSAGE, command_line); launch_error = CW2A(&create_proc_result_msg[0], CP_UTF8); *error_message = launch_error; } delete[] command_line; } process_id = proc_info.dwProcessId; if (process_id == NULL) { // If whatever API we are using failed to launch the browser, we should // have a NULL value in the dwProcessId member of the PROCESS_INFORMATION // structure. In that case, we will have already set the approprate error // message. On the off chance that we haven't yet set the appropriate // error message, that means we successfully launched the browser (i.e., // the browser launch API returned a success code), but we still have a // NULL process ID. if (launch_error.size() == 0) { *error_message = launch_api + NULL_PROCESS_ID_ERROR_MESSAGE; } } if (proc_info.hThread != NULL) { ::CloseHandle(proc_info.hThread); } if (proc_info.hProcess != NULL) { ::CloseHandle(proc_info.hProcess); } if (library_handle != NULL) { ::FreeLibrary(library_handle); } } else { *error_message = PROTECTED_MODE_SETTING_ERROR_MESSAGE; } return process_id; }
void main() { //vector<wstring> vFileNames = get_files_name(L"C:\\Users\\김송란\\Desktop\\송란이폴더\\랩세미나\\201603\\MunjaDB_IMG20160323\\*.bmp"); //vector<wstring> vFileNames = get_files_name(L"C:\\Users\\김송란\\Desktop\\송란이폴더\\랩세미나\\201603\\test\\*.bmp"); vector<wstring> vFileNames = get_files_name(L"C:\\Users\\김송란\\Documents\\GitHub\\MIPlab_seminar\\character recognition\\character recognition\\*.bmp"); //char *str; //sprintf(str, "%ls", vFileNames[0].c_str()); //wcout << vFileNames.size() << endl; //for (int i = 0; i < vFileNames.size(); i++) //{ // wcout << vFileNames[i] << endl; //} //int width, height; CHARACTER *Database_Char=(CHARACTER *)calloc(vFileNames.size(), sizeof(CHARACTER)); CHARACTER charname[50]; int a,b; string nameout; string test; vector<vector< string> > featureArr(600, vector<string>(600)); int file_count = vFileNames.size(); for (int i = 0; i < vFileNames.size(); i++) { test = CW2A(vFileNames[i].c_str());//wstring->string Mat A = imread(test, IMREAD_GRAYSCALE); // 파일명에서 알파벳 추출 a = test.find('['); b = test.find(']'); nameout = test.substr(a + 1, b-a-1); Database_Char[i].shape = nameout; Char_Feature(A,A.rows,A.cols, Database_Char[i]);//샘플특징 //int y = (int)(Database_Char[i].ratey * 100); //int x = (int)(Database_Char[i].ratex * 100); //featureArr[y][x] = Database_Char[i].shape; } Filename(file_count, Database_Char, charname); //중복되는 문자 하나로 Char_Feature_avg(charname, file_count, Database_Char);// 특징평균값 for (int i = 0; i < 50; i++) { cout << charname[i].shape<<" "<< charname[i].ratex << " " << charname[i].ratey <<" / "<< charname[i].avg1<< " / "<< charname[i].avg2<<" / "<< charname[i].avg3<<" / "<< charname[i].avg4<<endl; } int Optnum; CHARACTER input_Char; //string temp; //vector<wstring> inputfilenames = get_files_name(L"C:\\Users\\김송란\\Documents\\GitHub\\MIPlab_seminar\\character recognition\\character recognition\\*.bmp"); char dbname[200]; for (int i = 1; i <89; i++) { //sprintf(dbname, "C:\\Users\\김송란\\Documents\\카카오톡 받은 파일\\문자추출\\test%03d.bmp", i); sprintf(dbname, "C:\\Users\\김송란\\Documents\\카카오톡 받은 파일\\문자추출리사이즈\\resize%03d.bmp", i); Mat B = imread(dbname, IMREAD_GRAYSCALE); Char_Feature(B, B.rows, B.cols, input_Char); OptSample(charname, input_Char, &Optnum); cout << i << " 입력문자는 " << charname[Optnum].shape << "특징 - "<<charname[Optnum].avg1<< " / "<< charname[Optnum].avg2<<" / "<< charname[Optnum].avg3<<" / "<< charname[Optnum].avg4<<endl; } //CHARACTER input_Char; //Mat B = imread("C:\\Users\\김송란\\Documents\\GitHub\\MIPlab_seminar\\character recognition\\lineImg.bmp", IMREAD_GRAYSCALE); //입력 이미지 //Binary(B); ////imshow("input", B); ////waitKey(0); // ////라벨링 //Mat labelImage(B.rows, B.cols, CV_16UC1); //int label_count=connectedComponents(B, labelImage, 8); // 0까지 포함된 갯수임 ////imwrite("label.bmp", labelImage); // //int y_max[255] = { 0 }, x_max[255] = { 0 }; //int y_min[255], x_min[255]; //for (int i = 0; i < 255; i++) //{ // y_min[i] = B.rows; // x_min[i] = B.cols; //} // //Mat C(B.rows, B.cols, CV_8UC1); //for (int i = 0; i < B.rows; i++) // for (int j = 0; j < B.cols; j++) // { // C.at<unsigned char>(i, j) = B.at<unsigned char>(i, j); // } // //Find_MaxMin(labelImage, y_max, x_max, y_min, x_min); //MakingBox(labelImage, C,B, y_max, x_max, y_min, x_min, label_count); //imwrite("abc.bmp", C); //imshow("output", B); //waitKey(0); /* Char_Feature(B, B.rows, B.cols, input_Char); int y = (int)(input_Char.ratey * 100); int x = (int)(input_Char.ratex * 100); double err1, err2; double min_err1 = 100.0, min_err2 = 100.0; int c, d; for (int i = y - 10; i <= y + 10; i++) for (int j = x - 10; j <= x + 10; j++) { if (featureArr[i][j] != NULL) { err1 = abs(y - i); if (err1 < min_err1) { min_err1 = err1; err2 = abs(x - j); if (err2 < min_err2) { min_err2 = err2; c= i; d = j; } } } else cout << "없음" << endl; } cout << featureArr[c][d] << endl; */ //구조체 전달 확인 //opt_num=OptSample(Database_Char, input_Char,min_err,file_count); }
void CHideToolDlg::OnBnClickedButtonClosehide() { // TODO: 在此添加控件通知处理程序代码 WinExec(CW2A(_T("systemclose.bat")),SW_HIDE); }
void Update() { // maintain top/left pos CRect rcwnd; GetWindowRect(rcwnd); // Clear text m_wndRTF.SetWindowText(NULL); // Stream in new text... CComVariant bstr; std::string text; if(m_vertex) m_vertex->GetProperty(PROP_TOOLTIP, bstr); if(m_edge) m_edge->GetProperty(PROP_TOOLTIP, bstr); if (bstr.vt == VT_BSTR) text = CW2A(bstr.bstrVal); LPCSTR pstrText=text.c_str(); RtfStream st = { pstrText, 0 }; EDITSTREAM es = { 0 }; es.dwCookie = (DWORD) &st; es.dwError = 0; es.pfnCallback = _StreamReadCallback; UINT uFormat = pstrText[0]=='{' ? SF_RTF : SF_TEXT; m_wndRTF.StreamIn(uFormat, es); // Request new layout int cx = DEFAULT_WIDTH; CRect rc( 0, 0, cx, DEFAULT_HEIGHT); m_wndRTF.ResizeClient(cx, DEFAULT_HEIGHT, FALSE); m_wndRTF.SetRect(&rc); m_wndRTF.RequestResize(); CRect rcRTF(m_rcRTF); CRect rcOrig(m_rcRTF); // Resize RTF control until the height changes. This will indicate // the minimum/optimal width of the text. int iStep = 30; while( true ) { ATLASSERT(cx>0); CRect rc( 0, 0, cx - iStep, DEFAULT_HEIGHT); m_wndRTF.ResizeClient(cx - iStep, DEFAULT_HEIGHT, FALSE); m_wndRTF.SetRect(&rc); m_wndRTF.RequestResize(); if(rcRTF.Height() != m_rcRTF.Height()) { if( iStep <= 1 ) break; iStep /= 2; } else { cx -= iStep; if( cx <= 0 ) { rcRTF = rcOrig; break; } rcRTF = m_rcRTF; // Apply better width } } bool notnormal=IsIconic() || IsZoomed(); m_wndRTF.SetWindowPos(0, &rcRTF, (notnormal?0:SWP_SHOWWINDOW) | SWP_NOACTIVATE | SWP_NOZORDER); if(!notnormal) { DWORD exstyle=GetWndExStyle(0); rcwnd.right=rcwnd.left+rcRTF.Width(); rcwnd.bottom=rcwnd.top+rcRTF.Height(); ::AdjustWindowRectEx(&rcwnd, GetWndStyle(0), FALSE, exstyle); // finally, keep it inside screen bounds CRect rcScreen; ::SystemParametersInfo(SPI_GETWORKAREA, 0, &rcScreen, 0); if(rcwnd.right > rcScreen.right) rcwnd.OffsetRect(-(rcwnd.right-rcScreen.right), 0); if(rcwnd.top < rcScreen.top) rcwnd.OffsetRect(0, rcScreen.top-rcwnd.top); SetWindowPos(0, rcwnd, SWP_NOZORDER); } }
///////////////////////////////////////////////////////////////////// // // Function: // // Description: // ///////////////////////////////////////////////////////////////////// UINT CACreateProjectInitFile::OnExecution() { tstring strSetupExeName; tstring strDataDirectory; tstring strProjectInitUrl; tstring strProjectInitName; tstring strProjectInitTeamName; tstring strProjectInitAuthenticator; tstring strProjectInitSetupCookie; PROJECT_INIT pi; UINT uiReturnValue = -1; uiReturnValue = GetProperty( _T("DATADIR"), strDataDirectory ); if ( uiReturnValue ) return uiReturnValue; uiReturnValue = GetProperty( _T("PROJINIT_URL"), strProjectInitUrl ); if ( uiReturnValue ) return uiReturnValue; uiReturnValue = GetProperty( _T("PROJINIT_AUTH"), strProjectInitAuthenticator ); if ( uiReturnValue ) return uiReturnValue; uiReturnValue = GetProperty( _T("PROJINIT_TEAMNAME"), strProjectInitTeamName ); if ( uiReturnValue ) return uiReturnValue; uiReturnValue = GetProperty( _T("SETUPEXENAME"), strSetupExeName ); if ( uiReturnValue ) return uiReturnValue; LogMessage( INSTALLMESSAGE_INFO, NULL, NULL, NULL, NULL, _T("Changing to the data directory") ); _tchdir(strDataDirectory.c_str()); if (!strProjectInitUrl.empty()) { LogMessage( INSTALLMESSAGE_INFO, NULL, NULL, NULL, NULL, _T("Detected command line parameters") ); pi.init(); strncpy(pi.url, CW2A(strProjectInitUrl.c_str()), sizeof(pi.url)-1); strncpy(pi.name, CW2A(strProjectInitUrl.c_str()), sizeof(pi.name)-1); strncpy(pi.account_key, CW2A(strProjectInitAuthenticator.c_str()), sizeof(pi.account_key)-1); strncpy(pi.team_name, CW2A(strProjectInitTeamName.c_str()), sizeof(pi.team_name)-1); pi.embedded = false; pi.write(); } else { LogMessage( INSTALLMESSAGE_INFO, NULL, NULL, NULL, NULL, _T("Checking for file name parameters") ); strProjectInitUrl = ParseParameter(strSetupExeName, tstring(_T("amu"))); strProjectInitName = ParseParameter(strSetupExeName, tstring(_T("an"))); strProjectInitAuthenticator = ParseParameter(strSetupExeName, tstring(_T("aa"))); strProjectInitSetupCookie = ParseParameter(strSetupExeName, tstring(_T("asc"))); if (!strProjectInitUrl.empty() || !strProjectInitName.empty() || !strProjectInitAuthenticator.empty() || !strProjectInitSetupCookie.empty()) { LogMessage( INSTALLMESSAGE_INFO, NULL, NULL, NULL, NULL, _T("Detected file name parameters") ); pi.init(); if (!strProjectInitUrl.empty()) { LogMessage( INSTALLMESSAGE_INFO, NULL, NULL, NULL, NULL, _T("Detected project url") ); strncpy(pi.url, CW2A(strProjectInitUrl.c_str()), sizeof(pi.url)-1); pi.embedded = false; } if (!strProjectInitName.empty()) { LogMessage( INSTALLMESSAGE_INFO, NULL, NULL, NULL, NULL, _T("Detected project name") ); strncpy(pi.name, CW2A(strProjectInitName.c_str()), sizeof(pi.name)-1); } if (!strProjectInitAuthenticator.empty()) { LogMessage( INSTALLMESSAGE_INFO, NULL, NULL, NULL, NULL, _T("Detected project authenticator") ); strncpy(pi.account_key, CW2A(strProjectInitAuthenticator.c_str()), sizeof(pi.account_key)-1); } if (!strProjectInitSetupCookie.empty()) { LogMessage( INSTALLMESSAGE_INFO, NULL, NULL, NULL, NULL, _T("Detected setup cookie") ); strncpy(pi.setup_cookie, CW2A(strProjectInitSetupCookie.c_str()), sizeof(pi.setup_cookie)-1); } pi.write(); } } return ERROR_SUCCESS; }
jobject CWinRobotJNIAdapter::captureMouseCursorAsFileMapping(JNIEnv *env, jobject ori, jobject hotspot,jintArray pType) { CComQIPtr<IScreenBufferStream> pBuf ; LONG x=0,y=0,hotspotx=0,hotspoty = 0,type= CURSOR_UNKNOWN; try { pBuf = GetActiveConsoleSession()->CaptureMouseCursor(&x,&y,&hotspotx,&hotspoty,&type); } catch(_com_error e) { DebugOutF(filelog::log_error,"CaptureMouseCursor failed with 0x%x",e.Error()); } if (!pBuf) { RETURN(0); } if(ori) { jclass cls = env->GetObjectClass(ori); if (0 == cls) { RETURN(0); } jfieldID x_id = env->GetFieldID(cls, "x", "I"); if(x_id == 0) RETURN(0); jfieldID y_id = env->GetFieldID(cls, "y", "I"); if(y_id == 0) RETURN(0); if(ori)env->SetIntField(ori,x_id,x); if(ori)env->SetIntField(ori,y_id,y); } if(hotspot) { jclass cls = env->GetObjectClass(hotspot); if (0 == cls) { RETURN(0); } jfieldID x_id = env->GetFieldID(cls, "x", "I"); if(x_id == 0) RETURN(0); jfieldID y_id = env->GetFieldID(cls, "y", "I"); if(y_id == 0) RETURN(0); env->SetIntField(hotspot,x_id,hotspotx); env->SetIntField(hotspot,y_id,hotspoty); } if(pType){ jint temp[] = {type}; env->SetIntArrayRegion(pType,0,1,temp); } if(m_pCursor == pBuf && m_cursor_obj){ return env->NewLocalRef(m_cursor_obj); } CComBSTR fmname ; HRESULT hr ; if(FAILED(hr = pBuf->get_FileMappingName(&fmname))) { RETURN(0); } ULONG szie = 0; pBuf->get_Size(&szie); jclass jcls = env->FindClass("com/caoym/WinFileMappingBuffer"); if (0 == jcls) { JniException::Throw(env,"FindClass com/caoym/WinFileMappingBuffer failed"); return 0; } jmethodID ctor = env->GetMethodID(jcls, "<init>", "(Ljava/lang/String;I)V"); if (0 == ctor) { JniException::Throw(env,"find com/caoym/WinFileMappingBuffer constructor failed"); return 0; } jobject obj = env->NewObject(jcls,ctor,env->NewStringUTF(CW2A(fmname)),szie); if(m_cursor_obj)env->DeleteGlobalRef(m_cursor_obj); m_cursor_obj = env->NewGlobalRef(obj); m_pCursor = pBuf; return obj; }
jobject CWinRobotJNIAdapter::createScreenCaptureAsFileMapping(JNIEnv *env,jobject rc) { jclass cls = env->GetObjectClass(rc); if (0 == cls) { JniException::Throw(env,"GetObjectClass failed"); RETURN(0); } jfieldID x_id = env->GetFieldID(cls, "x", "I"); if(x_id == 0) RETURN(0); jfieldID y_id = env->GetFieldID(cls, "y", "I"); if(y_id == 0) RETURN(0); jfieldID w_id = env->GetFieldID(cls, "width", "I"); if(w_id == 0) RETURN(0); jfieldID h_id = env->GetFieldID(cls, "height", "I"); if(h_id == 0) RETURN(0); CComQIPtr<IScreenBufferStream> pBuf ; try { pBuf = GetActiveConsoleSession()->CreateScreenCapture( env->GetIntField(rc,x_id), env->GetIntField(rc,y_id), env->GetIntField(rc,w_id), env->GetIntField(rc,h_id)); } catch(_com_error e) { DebugOutF(filelog::log_error,"CreateScreenCapture failed with 0x%x",e.Error()); } if (!pBuf) { RETURN(0); } CComBSTR fmname ; HRESULT hr ; if(FAILED(hr = pBuf->get_FileMappingName(&fmname))) { RETURN(0); } ULONG szie = 0; pBuf->get_Size(&szie); jclass jcls = env->FindClass("com/caoym/WinFileMappingBuffer"); if (0 == jcls) { JniException::Throw(env,"FindClass com/caoym/WinFileMappingBuffer failed"); return 0; } jmethodID ctor = env->GetMethodID(jcls, "<init>", "(Ljava/lang/String;I)V"); if (0 == ctor) { JniException::Throw(env,"find com/caoym/WinFileMappingBuffer constructor failed"); return 0; } return env->NewObject(jcls,ctor,env->NewStringUTF(CW2A(fmname)),szie); }
int _tmain(int argc, _TCHAR* argv[]) { ISubtitles* subtitle = NULL; if (!ISubtitles::create(&subtitle)) { printf("failed to create subtitle instance.\n"); return 1; } #ifdef EMBEDDING_SUBTITLE av_register_all(); avformat_network_init(); AVFormatContext *fmt_ctx = NULL; char *url = LOCAL_FILE; int subtitle_stream_idx = -1; AVStream* subtitle_stream; AVCodecContext* subtitle_dec_ctx; AVPacket pkt; AVSubtitle sub; int got_sub; int ret; int index = 0; /* open input file, and allocate format context */ if (avformat_open_input(&fmt_ctx, url, NULL, NULL) < 0) { LOGE("Could not open source file"); return 1; } /* retrieve stream information */ if (avformat_find_stream_info(fmt_ctx, NULL) < 0) { LOGE("Could not find stream information\n"); return 1; } if (open_codec_context(fmt_ctx, &subtitle_stream_idx, AVMEDIA_TYPE_SUBTITLE) < 0) { LOGE("failed to find subttile track"); return 1; } subtitle_stream = fmt_ctx->streams[subtitle_stream_idx]; subtitle_dec_ctx = subtitle_stream->codec; /* dump input information to stderr */ av_dump_format(fmt_ctx, 0, url, 0); SubtitleCodecId codec_id; if (subtitle_dec_ctx->codec_id == AV_CODEC_ID_ASS || subtitle_dec_ctx->codec_id == AV_CODEC_ID_SSA) codec_id = SUBTITLE_CODEC_ID_ASS; else codec_id = SUBTITLE_CODEC_ID_TEXT; ret = subtitle->addEmbeddingSubtitle(codec_id, "chs", "chs", (const char *)subtitle_dec_ctx->extradata, subtitle_dec_ctx->extradata_size); if (ret < 0) { LOGE("failed to addEmbeddingSubtitle"); return 1; } /* initialize packet, set data to NULL, let the demuxer fill it */ av_init_packet(&pkt); pkt.data = NULL; pkt.size = 0; /* read frames from the file */ while (av_read_frame(fmt_ctx, &pkt) >= 0 && index < 10 ) { if (pkt.stream_index == subtitle_stream_idx) { AVPacket orig_pkt = pkt; do { ret = avcodec_decode_subtitle2(subtitle_dec_ctx, &sub, &got_sub, &pkt); if (ret < 0) { break; } if (got_sub) { LOGI("got subtitle"); for (int i=0;i<sub.num_rects;i++) { if (sub.rects[i]->ass) { int64_t start_time ,stop_time; AVRational ra; ra.num = 1; ra.den = AV_TIME_BASE; start_time = av_rescale_q(sub.pts + sub.start_display_time * 1000, ra, subtitle_stream->time_base); stop_time = av_rescale_q(sub.pts + sub.end_display_time * 1000, ra, subtitle_stream->time_base); subtitle->addEmbeddingSubtitleEntity(0, start_time, stop_time - start_time, sub.rects[i]->ass, strlen(sub.rects[i]->ass)); // my_strlen_utf8_c index++; } } avsubtitle_free(&sub); } pkt.data += ret; pkt.size -= ret; } while (pkt.size > 0); av_free_packet(&orig_pkt); } else { av_free_packet(&pkt); } } #else if (!subtitle->loadSubtitle(SUB_FILE_PATH, false)) { printf("failed to load subtitle: %s", SUB_FILE_PATH); return 1; } #endif STSSegment* segment = NULL; char subtitleText[1024] = {0}; int line = 0; while(line < 20 && subtitle->getNextSubtitleSegment(&segment)) { int64_t startTime = segment->getStartTime(); int64_t stopTime = segment->getStopTime(); segment->getSubtitleText(subtitleText, 1024); LOGI("%01d:%02d:%02d.%02d --> %01d:%02d:%02d.%02d %s", int(startTime/1000/3600), int(startTime/1000%3600/60), int(startTime/1000%60), int(startTime%1000)/10, int(stopTime/1000/3600), int(stopTime/1000%3600/60), int(stopTime/1000%60), int(stopTime%1000)/10, CW2A(CA2W(subtitleText, CP_UTF8))); //getchar(); line++; } subtitle->close(); return 0; }
void CWordDocumentProcessing::GetGrammarIntroTexts(int nBook,int nChapter,int nVerse,CString* strEnglish,CString* strTarget) { int i,j,k; CString strFileName,strReference,strCurrentReference,strEnglishSentence,strTargetSentence; BOOL b; CReferenceUtils ru; TbtaFileProcessing::TbtaTable tbtaTable; TbtaFileProcessing::TbtaTableRow tbtaTableRow; *strEnglish=L""; *strTarget=L""; strFileName=m_pDoc->GetPropertyString(2); //get the name of the Word doc where user has his Grammar Intro sentences if (strFileName==L"") { *strEnglish=L"(no document has been selected)"; return; } b=DoesFileExist(strFileName); if (!b) { *strEnglish=L"(the specified document does not exist)"; return; } strCurrentReference=ru.FormatReference(nBook,nChapter,nVerse,6,m_pDoc); std::string STDStr(CW2A(strFileName.GetString())); TbtaFileProcessing::TbtaFileProcessor::Initialize(); //the initialize and terminate functions can just be called from the main method, they don't have to be called for every function. But Initialize does need to be called before creating any TbtaFileProcessor instances. try { std::vector<TbtaFileProcessing::TbtaTable> tables = TbtaFileProcessing::TbtaFileProcessor::GetAllTables(STDStr); if (tables.size()>0) //if there are some tables in the doc { for (i=0; i<tables.size(); i++) //for each table { tbtaTable=tables[i]; for (j=1; j<tbtaTable.size(); j++) //for each row { tbtaTableRow=tbtaTable[j]; strReference=tbtaTableRow[0]; k=strReference.Find(L":"); if (k>-1) { k=strReference.Find(L" ",k); //find the first space after the colon if (k>0) strReference=strReference.Left(k); //remove the comments after the reference if (strReference==strCurrentReference) //if this row in the table corresponds to this verse in the Grammar Intro { strEnglishSentence=tbtaTableRow[1]; //get the English sentence strEnglishSentence=strCurrentReference+L" "+strEnglishSentence; //put the reference at the beginning strTargetSentence=tbtaTableRow[3]; strTargetSentence=FindEndOfExample(strTargetSentence); //trim the example so that it doesn't include the user's notes } } } } } } catch (const TbtaFileProcessing::FileProcessingException& e) { //error handling code here } TbtaFileProcessing::TbtaFileProcessor::Terminate(); *strEnglish=strEnglishSentence; *strTarget=strTargetSentence; }
BOOL __stdcall AtlTraceSaveSettingsA(const CHAR *pszFileName, DWORD_PTR dwProcess /* = 0 */) { ATLASSERT(pszFileName); if(!pszFileName) return FALSE; BOOL bRetVal = FALSE; CHAR szKey[MAX_PATH], szValue[MAX_PATH]; UINT nCategories, nStatus; CAtlTraceProcess *pProcess; CAtlTraceModule *pModule; CAtlTraceCategory *pCategory; LPCSTR pszProcess = "Process"; CAtlAllocator *pAllocator = &g_Allocator; if (dwProcess) pAllocator = reinterpret_cast<CAtlAllocator*>(dwProcess); pProcess = pAllocator->GetProcess(); ATLASSERT(pProcess); if(!pProcess) return FALSE; bRetVal = TRUE; ATLTRACEPROCESSINFO info; AtlTraceGetProcessInfo(dwProcess, &info); #if _SECURE_ATL if(-1 == sprintf_s(szValue, MAX_PATH, "ModuleCount:%u, Level:%u, Enabled:%c, " "FuncAndCategoryNames:%c, FileNameAndLineNo:%c", info.nModules, pProcess->m_nLevel, pProcess->m_bEnabled ? 't' : 'f', pProcess->m_bFuncAndCategoryNames ? 't' : 'f', pProcess->m_bFileNameAndLineNo ? 't' : 'f')) { return FALSE; } #else sprintf(szValue, "ModuleCount:%u, Level:%u, Enabled:%c, " "FuncAndCategoryNames:%c, FileNameAndLineNo:%c", info.nModules, pProcess->m_nLevel, pProcess->m_bEnabled ? 't' : 'f', pProcess->m_bFuncAndCategoryNames ? 't' : 'f', pProcess->m_bFileNameAndLineNo ? 't' : 'f'); #endif if(::WritePrivateProfileStringA(pszProcess, "Info", szValue, pszFileName) == 0) return FALSE; for(int i = 0; i < info.nModules; i++) { pModule = pAllocator->GetModule(i); ATLASSERT(pModule); if(!pModule) return FALSE; #if _SECURE_ATL if(-1 == sprintf_s(szKey, MAX_PATH, "Module%d", i+1)) return FALSE; #else sprintf(szKey, "Module%d", i+1); #endif if(::WritePrivateProfileStringA(pszProcess, szKey, CW2A(pModule->Name()), pszFileName) == 0) return FALSE; GetSettings(*pModule, &nStatus); nCategories = pAllocator->GetCategoryCount(i); if(::WritePrivateProfileStringA(CW2A(pModule->Name()), "Name", CW2A(pModule->Path()), pszFileName) == 0) return FALSE; #if _SECURE_ATL if(-1 == sprintf_s(szValue, MAX_PATH, "CategoryCount:%u, Level:%u, Status:%u", nCategories, pModule->m_nLevel, nStatus)) return FALSE; #else sprintf(szValue, "CategoryCount:%u, Level:%u, Status:%u", nCategories, pModule->m_nLevel, nStatus); #endif if(::WritePrivateProfileStringA(CW2A(pModule->Name()), "Settings", szValue, pszFileName) == 0) return FALSE; int j = 0; UINT nCategory = pModule->m_iFirstCategory; while( nCategory != UINT( -1 ) ) { pCategory = pAllocator->GetCategory(nCategory); GetSettings(*pCategory, &nStatus); #if _SECURE_ATL if(-1 == sprintf_s(szKey, MAX_PATH, "Category%d", j+1)) return FALSE; #else sprintf(szKey, "Category%d", j+1); #endif j++; #if _SECURE_ATL if(-1 == sprintf_s(szValue, MAX_PATH, "Level:%u, Status:%u, Name:%S", pCategory->m_nLevel, nStatus, pCategory->Name())) { return FALSE; } #else sprintf(szValue, "Level:%u, Status:%u, Name:%S", pCategory->m_nLevel, nStatus, pCategory->Name()); #endif if(::WritePrivateProfileStringA(CW2A(pModule->Name()), szKey, szValue, pszFileName) == 0) return FALSE; nCategory = pCategory->m_iNextCategory; } } return bRetVal; }
CStringW sGetMessage(const CString& section, const CString& key) { Dictionary* dictionary = Dictionary::GetInstance(); return CStringW(dictionary->Lookup(std::string(CW2A(section)), std::string(CW2A(key))).c_str()); }
int CDownFile::InternetGetFile(CString szUrl,CString szFileName) { DWORD dwFlags; InternetGetConnectedState(&dwFlags, 0); CHAR strAgent[64]; sprintf(strAgent, "Agent%ld", timeGetTime()); HINTERNET hOpen; if(!(dwFlags & INTERNET_CONNECTION_PROXY)) hOpen = InternetOpenA(strAgent, INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY, NULL, NULL, 0); else hOpen = InternetOpenA(strAgent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); if(!hOpen) { //AfxMessageBox("Internet连接错误!"); return -1; } DWORD dwSize; CHAR szHead[] = "Accept: */*\r\n\r\n"; VOID* szTemp[16384]; HINTERNET hConnect; CFile file; USES_CONVERSION; if ( !(hConnect = InternetOpenUrlA ( hOpen,CW2A(szUrl), szHead, lstrlenA (szHead), INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_RELOAD, 0))) { // AfxMessageBox("不能打开该URL!"); return -1; } if (file.Open(szFileName,CFile::modeWrite|CFile::modeCreate)==FALSE ) { //AfxMessageBox("不能打开本地的文件!"); return -1; } DWORD dwByteToRead = 0; DWORD dwSizeOfRq = 4; DWORD dwBytes = 0; if (!HttpQueryInfo(hConnect, HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER, (LPVOID)&dwByteToRead, &dwSizeOfRq, NULL)) { dwByteToRead = 0; } do { if (!InternetReadFile (hConnect, szTemp, 16384, &dwSize)) { //AfxMessageBox("读文件出错!"); file.Close(); return -1; } if (dwSize==0) break; else file.Write(szTemp,dwSize); dwBytes+=dwSize; }while (TRUE); file.Close(); InternetCloseHandle(hOpen); return 0; }
BOOL CPostData::UseHttpSendReqEx( std::string& lpost) { USES_CONVERSION; long lgg; CString strtemp; lgg = lpost.size(); INTERNET_BUFFERS BufferIn; DWORD dwBytesWritten; BOOL bRet; TCHAR head[1024]; std::wstring strt = MS_CONTENTTYPE; std::wstring strt1 = CA2W(CSNManager::GetInstance()->GetSN().c_str()); //_stprintf_s(head, _countof(head), _T("%s\r\nSN: %s;\r\nMoneyhubuid: %s;\r\n"), strt.c_str() ,strt1.c_str() ,m_strHWID.c_str()); _stprintf_s(head, _countof(head), _T("Sn: %s\r\nMoneyhubuid: %s\r\n"), strt1.c_str() ,m_strHWID.c_str()); //TCHAR head[]= strt.c_str(); BufferIn.dwStructSize = sizeof( INTERNET_BUFFERS ); // Must be set or error will occur BufferIn.Next = NULL; BufferIn.lpcszHeader = head; BufferIn.dwHeadersLength = 0; BufferIn.dwHeadersTotal = sizeof(head); BufferIn.lpvBuffer = (LPSTR)lpost.c_str(); BufferIn.dwBufferLength = 0; BufferIn.dwBufferTotal = lgg; // This is the only member used other than dwStructSize BufferIn.dwOffsetLow = 0; BufferIn.dwOffsetHigh = 0; DWORD dwFlags = 0; DWORD dwBuffLen = sizeof(dwFlags); InternetQueryOption (m_hInetFile, INTERNET_OPTION_SECURITY_FLAGS, (LPVOID)&dwFlags, &dwBuffLen); dwFlags |= (SECURITY_FLAG_IGNORE_UNKNOWN_CA | SECURITY_FLAG_IGNORE_CERT_CN_INVALID); InternetSetOption (m_hInetFile, INTERNET_OPTION_SECURITY_FLAGS, &dwFlags, sizeof (dwFlags) ); if(!HttpSendRequestEx( m_hInetFile, &BufferIn, NULL, 0, 0)) { strtemp.Format(_T("Error on HttpSendRequestEx %d\n"),GetLastError()); int nLen = strtemp.GetLength(); strt =strtemp.GetBuffer(nLen); strtemp.ReleaseBuffer(); CRecordProgram::GetInstance()->RecordWarnInfo(MY_PRO_NAME, MY_COMMON_ERROR, strt); CRecordProgram::GetInstance()->RecordWarnInfo(MY_PRO_NAME, MY_COMMON_ERROR, L"HttpSendRequestEx"); CloseHandles(); printf( "Error on HttpSendRequestEx %d\n",GetLastError() ); return FALSE; } bRet=TRUE; bRet = InternetWriteFile( m_hInetFile, (LPSTR)lpost.c_str(), lgg, &dwBytesWritten); if(!bRet) { strtemp.Format(_T("Error on HttpSendRequestEx %d\n"),GetLastError()); int nLen = strtemp.GetLength(); strt =strtemp.GetBuffer(nLen); strtemp.ReleaseBuffer(); CRecordProgram::GetInstance()->RecordWarnInfo(MY_PRO_NAME, MY_COMMON_ERROR, strt); CRecordProgram::GetInstance()->RecordWarnInfo(MY_PRO_NAME, MY_COMMON_ERROR, L"HttpSendRequestEx InternetWriteFile"); CloseHandles(); printf( "\nError on InternetWriteFile %lu\n",GetLastError() ); return FALSE; } bRet = HttpEndRequest(m_hInetFile, NULL, 0, 0); if(!bRet) { strtemp.Format(_T("Error on HttpSendRequestEx %d\n"),GetLastError()); int nLen = strtemp.GetLength(); strt =strtemp.GetBuffer(nLen); strtemp.ReleaseBuffer(); CRecordProgram::GetInstance()->RecordWarnInfo(MY_PRO_NAME, MY_COMMON_ERROR, strt); CRecordProgram::GetInstance()->RecordWarnInfo(MY_PRO_NAME, MY_COMMON_ERROR, L"HttpSendRequestEx HttpEndRequest"); CloseHandles(); printf( "Error on HttpEndRequest %lu \n", GetLastError()); return FALSE; } char pcBuffer[BUFFSIZE]; DWORD dwBytesRead; LPSTR lpszData1; lpszData1 = new char[1024*1024]; lpszData1[0]='\0'; //printf("\nThe following was returned by the server:\n"); do { dwBytesRead=0; if(InternetReadFile(m_hInetFile, pcBuffer, BUFFSIZE-1, &dwBytesRead)) { pcBuffer[dwBytesRead]=0x00; // Null-terminate buffer strcat(lpszData1,pcBuffer); //printf("%s", pcBuffer); } else return FALSE; //lpszData1 =""; //printf("\nInternetReadFile failed"); }while(dwBytesRead>0); //printf("\n"); lpost = ""; lpost = CW2A(UTF8ToUnicode(lpszData1).c_str()); delete []lpszData1; CloseHandles(); //return ERR_SUCCESS; return TRUE; }
HANDLE WINAPI MyDetourCreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) { if (lpFileName == NULL) return MyOldCreateFileW(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); std::wstring wstrPath = lpFileName; HANDLE hFile = NULL;//MyOldCreateFileW(strFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); #ifdef OFFICIAL_VERSION std::string strPath; strPath = CW2A(lpFileName); // 匹配,看是否需要解密 if (g_pRegKeyManager->IsEncryptFile((LPSTR)strPath.c_str())) { std::map<string, HANDLE>::iterator cstIt; cstIt = g_FileNHMap.find(strPath); if(g_FileNHMap.end() == cstIt) { hFile = MyOldCreateFileW(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); if (INVALID_HANDLE_VALUE == hFile) return INVALID_HANDLE_VALUE; DWORD dwFileSize = GetFileSize(hFile, NULL); if (dwFileSize > 0) { char* pBuff = new char[dwFileSize + 1]; memset(pBuff, 0, dwFileSize + 1); DWORD dwRead = 0; BOOL bBack = ReadFile(hFile, pBuff, dwFileSize, &dwRead, NULL); if(bBack) { int nLen = dwRead + 1; unsigned char* pOutData = new unsigned char[nLen]; memset (pOutData, 0, nLen); // 解密 int nLenWrite = JSFileUnPack((unsigned char *)pBuff, dwRead, pOutData); delete []pBuff; pBuff = NULL; g_FileMap.insert(std::make_pair(hFile, pOutData)); g_FileNHMap.insert(std::make_pair(strPath, hFile)); } else { delete []pBuff; pBuff = NULL; } } } else hFile = (*cstIt).second; } else hFile = MyOldCreateFileW(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); #else hFile = MyOldCreateFileW(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); #endif //} return hFile; }
myLogStructure MyLogStructure::toStruct(int summarizationLevel, string processName1, string eventCategory1) { //sizeOfEvent = sizeOfEvent + str_eventID.length() + str_level.length() + str_executionProcessID.length() + str_eventMessageString.length(); myLogStructure m; m.processName = processName1; m.eventCategory = eventCategory1; m.myTimeStamp1 = timeStamp.toTimeStampStruct(); if (summarizationLevel == 2) // High level summarization. { if (message) { m.message = CW2A(message); } m.levelMessageString = CW2A(levelMessageString); //m.taskMessageString = CW2A(taskMessageString); //m.opCodeMessageString = CW2A(opCodeMessageString); //m.channelMessageString = CW2A(channelMessageString); //m.providerMessageString = CW2A(providerMessageString); //m.keywords = keywords; m.executionProcessID = to_string(executionProcessID); m.executionThreadID = to_string(executionThreadID); if (computer) { m.computer = CW2A(computer); } m.EventID = to_string(EventID); } else if (summarizationLevel == 1) // Medium level summarization. { if (message) { m.message = CW2A(message); } if (levelMessageString) { m.levelMessageString = CW2A(levelMessageString); } if (taskMessageString) { m.taskMessageString = CW2A(taskMessageString); } //m.opCodeMessageString = CW2A(opCodeMessageString); //m.channelMessageString = CW2A(channelMessageString); if (providerMessageString) { m.providerMessageString = CW2A(providerMessageString); } //m.keywords = keywords; m.executionProcessID = to_string(executionProcessID); m.executionThreadID = to_string(executionThreadID); if (computer) { m.computer = CW2A(computer); } m.EventID = to_string(EventID); } else { if (message) { m.message = CW2A(message); } if (levelMessageString) { m.levelMessageString = CW2A(levelMessageString); } if (taskMessageString) { m.taskMessageString = CW2A(taskMessageString); } if (opCodeMessageString) { m.opCodeMessageString = CW2A(opCodeMessageString); } if (channelMessageString) { m.channelMessageString = CW2A(channelMessageString); } if (providerMessageString) { m.providerMessageString = CW2A(providerMessageString); } m.keywords = to_string(keywords); m.executionProcessID = to_string(executionProcessID); m.executionThreadID = to_string(executionThreadID); if (computer) { m.computer = CW2A(computer); } m.EventID = to_string(EventID); } if (summarizationLevel == 2) // High level summarization. Drop some object level information { if (isAvailableMySubject) { m.mySubject1 = mySubject->toLogStruct(summarizationLevel); } if (isAvailableMyObject) { m.myObject1 = myObject->toLogStruct(summarizationLevel); } if (isAvailableMyProcessInformation) { m.myProcessInformation1 = myProcessInformation->toLogStruct(summarizationLevel); } if (isAvailableMyApplicationInformation) { m.myApplicationInformation1 = myApplicationInformation->toLogStruct(summarizationLevel); } if (isAvailableMyNetworkInformation) { m.myNetworkInformation1 = myNetworkInformation->toLogStruct(summarizationLevel); } if (isAvailableMyProviderInformation) { //m.myProviderInformation1 = myProviderInformation->toLogStruct(summarizationLevel); } if (isAvailableMyChangeInformation) { m.myChangeInformation1 = myChangeInformation->toLogStruct(summarizationLevel); } if (isAvailableMyAccessRequestInformation) { m.myAccessRequestInformation1 = myAccessRequestInformation->toLogStruct(summarizationLevel); } if (isAvailableMyFilterInformation) { //m.myFilterInformation1 = myFilterInformation->toLogStruct(summarizationLevel); } if (isAvailableMyLayerInformation) { //m.myLayerInformation1 = myLayerInformation->toLogStruct(summarizationLevel); } if (isAvailableMyCalloutInformation) { //m.myCalloutInformation1 = myCalloutInformation->toLogStruct(summarizationLevel); } if (isAvailableMyRuleInformation) { //m.myRuleInformation1 = myRuleInformation->toLogStruct(summarizationLevel); } if (isAvailableMyErrorInformation) { m.myErrorInformation1 = myErrorInformation->toLogStruct(summarizationLevel); } } else { if (isAvailableMySubject) { m.mySubject1 = mySubject->toLogStruct(summarizationLevel); } if (isAvailableMyObject) { m.myObject1 = myObject->toLogStruct(summarizationLevel); } if (isAvailableMyProcessInformation) { m.myProcessInformation1 = myProcessInformation->toLogStruct(summarizationLevel); } if (isAvailableMyApplicationInformation) { m.myApplicationInformation1 = myApplicationInformation->toLogStruct(summarizationLevel); } if (isAvailableMyNetworkInformation) { m.myNetworkInformation1 = myNetworkInformation->toLogStruct(summarizationLevel); } if (isAvailableMyProviderInformation) { m.myProviderInformation1 = myProviderInformation->toLogStruct(summarizationLevel); } if (isAvailableMyChangeInformation) { m.myChangeInformation1 = myChangeInformation->toLogStruct(summarizationLevel); } if (isAvailableMyAccessRequestInformation) { m.myAccessRequestInformation1 = myAccessRequestInformation->toLogStruct(summarizationLevel); } if (isAvailableMyFilterInformation) { m.myFilterInformation1 = myFilterInformation->toLogStruct(summarizationLevel); } if (isAvailableMyLayerInformation) { m.myLayerInformation1 = myLayerInformation->toLogStruct(summarizationLevel); } if (isAvailableMyCalloutInformation) { m.myCalloutInformation1 = myCalloutInformation->toLogStruct(summarizationLevel); } if (isAvailableMyRuleInformation) { m.myRuleInformation1 = myRuleInformation->toLogStruct(summarizationLevel); } if (isAvailableMyErrorInformation) { m.myErrorInformation1 = myErrorInformation->toLogStruct(summarizationLevel); } } //m.channel = CW2A(channel); //m.version = version; //m.level = level; //m.task = task; //m.opCode = opCode; //m.eventRecordID = eventRecordID; //m.channel = CW2A(channel); return m; }
int Script::ConvertResultToJsonValue(const IECommandExecutor& executor, Json::Value* value) { LOG(TRACE) << "Entering Script::ConvertResultToJsonValue"; int status_code = SUCCESS; if (this->ResultIsString()) { std::string string_value = ""; if (this->result_.bstrVal) { string_value = CW2A(this->result_.bstrVal, CP_UTF8); } *value = string_value; } else if (this->ResultIsInteger()) { *value = this->result_.lVal; } else if (this->ResultIsDouble()) { *value = this->result_.dblVal; } else if (this->ResultIsBoolean()) { *value = this->result_.boolVal == VARIANT_TRUE; } else if (this->ResultIsEmpty()) { *value = Json::Value::null; } else if (this->result_.vt == VT_NULL) { *value = Json::Value::null; } else if (this->ResultIsIDispatch()) { if (this->ResultIsArray() || this->ResultIsElementCollection()) { Json::Value result_array(Json::arrayValue); long length = 0; status_code = this->GetArrayLength(&length); for (long i = 0; i < length; ++i) { Json::Value array_item_result; int array_item_status = this->GetArrayItem(executor, i, &array_item_result); result_array[i] = array_item_result; } *value = result_array; } else if (this->ResultIsObject()) { Json::Value result_object; std::wstring property_name_list = L""; status_code = this->GetPropertyNameList(&property_name_list); std::vector<std::wstring> property_names; size_t end_position(0); size_t start_position(0); while (true) { std::wstring property_name = L""; end_position = property_name_list.find_first_of(L",", start_position); if(end_position == std::wstring::npos) { property_names.push_back(property_name_list.substr(start_position, property_name_list.size() - start_position)); break; } else { property_names.push_back(property_name_list.substr(start_position, end_position - start_position)); start_position = end_position + 1; } } for (size_t i = 0; i < property_names.size(); ++i) { Json::Value property_value_result; int property_value_status = this->GetPropertyValue(executor, property_names[i], &property_value_result); std::string name(CW2A(property_names[i].c_str(), CP_UTF8)); result_object[name] = property_value_result; } *value = result_object; } else { LOG(INFO) << "Unknown type of dispatch is found in result, assuming IHTMLElement"; IECommandExecutor& mutable_executor = const_cast<IECommandExecutor&>(executor); IHTMLElement* node = reinterpret_cast<IHTMLElement*>(this->result_.pdispVal); ElementHandle element_wrapper; mutable_executor.AddManagedElement(node, &element_wrapper); *value = element_wrapper->ConvertToJson(); } } else { LOG(WARN) << "Unknown type of result is found"; status_code = EUNKNOWNSCRIPTRESULT; } return status_code; }
static utf8_string utf(utf16_char const* str, size_t size) { utf8_string tmp = CW2A(str, CP_UTF8); return tmp; //utf16_to_utf8(str, size); }
static std::basic_string<char> convert(const std::basic_string<wchar_t> &str, size_t code) { return std::move(std::basic_string<char>(CW2A(str.c_str(), code))); }
void CNetLayer::SetNetAddress(void * pu) { LPWSTR * szArgList = (LPWSTR *)pu; m_strAddress = CW2A(szArgList[1]); m_strPort = CW2A(szArgList[2]); }
static utf8_string utf(utf8_char const* str, size_t size) { utf16_string wide = CA2W(str); utf8_string tmp = CW2A(wide.c_str(), CP_UTF8); return tmp; }
/** * @param strFilePath - document file path. */ void CExpressModeDlg::LoadXMLDocument(const CString& strFilePath) { ClearData(); HRESULT hRes = m_pXMLDocument.CoCreateInstance(CLSID_DOMDocument60, NULL, CLSCTX_INPROC_SERVER); CHECK_HRESULT(hRes); m_pXMLDocument->setProperty(CComBSTR(OLESTR("SelectionLanguage")), CComVariant(OLESTR("XPath"))); m_pXMLDocument->put_async(VARIANT_FALSE); VARIANT_BOOL bSuccess = VARIANT_FALSE; hRes = m_pXMLDocument->load(CComVariant(strFilePath), &bSuccess); CHECK_HRESULT(hRes); if (! bSuccess) { CComPtr<IXMLDOMParseError> pXMLError; hRes = m_pXMLDocument->get_parseError(&pXMLError); if (hRes == S_OK) { long lErrorCode = 0; pXMLError->get_errorCode(&lErrorCode); if (lErrorCode != 0) { CComBSTR bstrError; pXMLError->get_reason(&bstrError); throw com_error(lErrorCode, CW2A(bstrError)); } } CStringA strError; strError.LoadString(IDS_ERROR_XMLLOADERROR); throw com_error(strError); } hRes = m_pXMLDocument->get_documentElement(&m_pXMLElementDocument); CHECK_HRESULT(hRes); CComVariant varReportVersion; hRes = m_pXMLElementDocument->getAttribute(CComBSTR(OLESTR("version")), &varReportVersion); CHECK_HRESULT(hRes); if (hRes == S_OK) { hRes = varReportVersion.ChangeType(VT_I4); CHECK_HRESULT(hRes); if (V_I4(&varReportVersion) != 1) { CStringA strErrorMessage; strErrorMessage.LoadString(IDS_ERROR_UNSUPPORTEDREPORTVERSION); throw com_error(strErrorMessage); } } if (GetXMLNodeText(m_pXMLElementDocument, OLESTR("./platform"), m_strPlatform)) { // validate platform GetPlatform(); } if (SelectXMLNode(m_pXMLElementDocument, OLESTR("./error"), m_pXMLNodeError)) { CString strProcessID; GetXMLNodeText(m_pXMLNodeError, OLESTR("./process/id"), strProcessID); if (! strProcessID.IsEmpty()) { CString strExpression; strExpression.Format(_T("./processes/process[id=%s]"), strProcessID); SelectXMLNode(m_pXMLElementDocument, CT2W(strExpression), m_pXMLNodeProcess); } } }
void WINAPI CreatePayCardPlatformW(LPCWSTR lpszParams) { CreatePayCardPlatformA(CW2A(lpszParams)); }
BOOL WINAPI DdnInitializePcpW(LPCWSTR lpszParams) { return DdnInitializePcpA(CW2A(lpszParams)); }
void CWordDocumentProcessing::GetText(int nSourceText,int nBook,int nChapter,int nVerse,int nSentence,CString* strEnglish,CString* strTarget) //get the English sentence and target translation from the Word doc { int i,j,k; CString T,strFileName,strReference,strCurrentReference,strEnglishSentence,strTargetSentence; wchar_t c[5]; BOOL b; CReferenceUtils ru; TbtaFileProcessing::TbtaTable tbtaTable; TbtaFileProcessing::TbtaTableRow tbtaTableRow; *strEnglish=L""; *strTarget=L""; if (nSourceText==4 || nSourceText==3) //if in the Bible or missions docs { if (nBook==1) strFileName=m_pDoc->GetPropertyString(11); //get the Word doc for Genesis if (nBook==8) strFileName=m_pDoc->GetPropertyString(7); //get the Word doc for Ruth if (nBook==27) strFileName=m_pDoc->GetPropertyString(12); //get the Word doc for Daniel if (nBook==42) strFileName=m_pDoc->GetPropertyString(10); //get the Word doc for Luke } else if (nSourceText==7) //else in a community development text { strFileName=m_pDoc->GetPropertyString(nBook+3); //get the name of the Word doc where user has his Community Development sentences } else { return; } if (strFileName==L"") { *strEnglish=L"(no document has been selected)"; return; } b=DoesFileExist(strFileName); if (!b) { *strEnglish=L"(the specified document does not exist)"; return; } strCurrentReference=ru.FormatReference(nBook,nChapter,nVerse,nSourceText,m_pDoc); if (nSentence>0) //if in single sentence mode { _itow(nSentence,c,10); T=c; strCurrentReference+=L":"+T; } std::string STDStr(CW2A(strFileName.GetString())); TbtaFileProcessing::TbtaFileProcessor::Initialize(); //the initialize and terminate functions can just be called from the main method, they don't have to be called for every function. But Initialize does need to be called before creating any TbtaFileProcessor instances. try { std::vector<TbtaFileProcessing::TbtaTable> tables = TbtaFileProcessing::TbtaFileProcessor::GetAllTables(STDStr); if (tables.size()>0) //if there are some tables in the doc { for (i=0; i<tables.size(); i++) //for each table { tbtaTable=tables[i]; for (j=0; j<tbtaTable.size(); j++) //for each row { tbtaTableRow=tbtaTable[j]; strReference=tbtaTableRow[0]; k=strReference.Find(L":"); if (k>-1) { k=strReference.Find(L" ",k); //find the first space after the colon if (k>0) strReference=strReference.Left(k); //remove the comments after the reference if (strReference==strCurrentReference) //if this row in the table corresponds to this verse in the Grammar Intro { strEnglishSentence=tbtaTableRow[1]; //get the English sentence strEnglishSentence=strCurrentReference+L" "+strEnglishSentence; //put the reference at the beginning strTargetSentence=tbtaTableRow[2]; if (nSentence>0) strTargetSentence=FindEndOfExample(strTargetSentence); //trim the example so that it doesn't include the user's notes } } } } } } catch (const TbtaFileProcessing::FileProcessingException& e) { //error handling code here } TbtaFileProcessing::TbtaFileProcessor::Terminate(); *strEnglish=strEnglishSentence; *strTarget=strTargetSentence; }
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPTSTR, int aNumberCommands) { ShowCursor(true); DL_Debug::Debug::Create(); CU::TimerManager::Create(); if (aNumberCommands > 2) { int commandCount = 0; LPWSTR* realCommands = CommandLineToArgvW(GetCommandLineW(), &commandCount); for (int i = 1; i < commandCount; ++i) { std::string command = CW2A(realCommands[i]); if (command == "-useEngineLog") { DL_Debug::Debug::GetInstance()->ActivateFilterLog(DL_Debug::eFilterLog::ENGINE); } else if (command == "-useGameLog") { DL_Debug::Debug::GetInstance()->ActivateFilterLog(DL_Debug::eFilterLog::GAME); } else if (command == "-useResourceLog") { DL_Debug::Debug::GetInstance()->ActivateFilterLog(DL_Debug::eFilterLog::RESOURCE); } else if (command == "-useDirectXLog") { DL_Debug::Debug::GetInstance()->ActivateFilterLog(DL_Debug::eFilterLog::DIRECTX); } else if (command == "-useFBXLog") { DL_Debug::Debug::GetInstance()->ActivateFilterLog(DL_Debug::eFilterLog::FBX); } else if (command == "-useFunctionTimerLog") { DL_Debug::Debug::GetInstance()->ActivateFilterLog(DL_Debug::eFilterLog::FUNCTION_TIMER); } else if (command == "-useEntityLog") { DL_Debug::Debug::GetInstance()->ActivateFilterLog(DL_Debug::eFilterLog::ENTITY); } } LocalFree(realCommands); } if (ReadSetup(globalSetup, CU::GetMyDocumentFolderPath() + "Raven\\Data\\Setting\\SET_config.bin") == false) { return 1; } HWND hwnd; if (Prism::Engine::Create(hwnd, WndProc, globalSetup) == false) { return 1; } globalGame = new Game(); if (globalGame->Init(hwnd) == false) { return 1; } SetActiveWindow(hwnd); globalPreviousFullscreenState = Prism::Engine::GetInstance()->IsFullscreen(); #ifdef RELEASE_BUILD Prism::Engine::GetInstance()->SetFullscreen(true); globalPreviousFullscreenState = true; #endif MSG msg; while (1) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (msg.message == WM_QUIT) { break; } TranslateMessage(&msg); DispatchMessage(&msg); } else { if (globalGame->Update() == false) { break; } Prism::Engine::GetInstance()->Render(); } } globalGame->Destroy(); delete globalGame; globalGame = nullptr; Prism::Engine::Destroy(); return 0; }