CSerial::EStopBits CSerial::GetStopBits (void) { // Reset error state m_lLastError = ERROR_SUCCESS; // Check if the device is open if (m_hFile == 0) { // Set the internal error code m_lLastError = ERROR_INVALID_HANDLE; // Issue an error and quit _RPTF0(_CRT_WARN,"CSerial::GetStopBits - Device is not opened\n"); return EStopUnknown; } // Obtain the DCB structure for the device CDCB dcb; if (!::GetCommState(m_hFile,&dcb)) { // Obtain the error code m_lLastError = ::GetLastError(); // Display a warning _RPTF0(_CRT_WARN,"CSerial::GetStopBits - Unable to obtain DCB information\n"); return EStopUnknown; } // Return the appropriate stopbits return EStopBits(dcb.StopBits); }
LONG CSerial::SetMask (DWORD dwEventMask) { // Reset error state m_lLastError = ERROR_SUCCESS; // Check if the device is open if (m_hFile == 0) { // Set the internal error code m_lLastError = ERROR_INVALID_HANDLE; // Issue an error and quit _RPTF0(_CRT_WARN,"CSerial::SetMask - Device is not opened\n"); return m_lLastError; } // Set the new mask. Note that this will generate an EEventNone // if there is an asynchronous WaitCommEvent pending. if (!::SetCommMask(m_hFile,dwEventMask)) { // Obtain the error code m_lLastError = ::GetLastError(); // Display a warning _RPTF0(_CRT_WARN,"CSerial::SetMask - Unable to set event mask\n"); return m_lLastError; } // Save event mask and return successful m_dwEventMask = dwEventMask; return m_lLastError; }
DWORD CNTSerial::GetEventMask (void) { // Reset error state m_lLastError = ERROR_SUCCESS; // Check if the device is open if (m_hFile == 0) { // Set the internal error code m_lLastError = ERROR_INVALID_HANDLE; // Issue an error and quit _RPTF0(_CRT_WARN,"CNTSerial::GetEventMask - Device is not opened\n"); return 0; } // Obtain the COM mask DWORD dwMask = 0; if (!::GetCommMask(m_hFile, &dwMask)) { // Set the internal error code m_lLastError = ::GetLastError(); // Issue an error and quit _RPTF0(_CRT_WARN,"CNTSerial::GetEventMask - Unable to get the event mask\n"); return 0; } // Return the event mask return dwMask; }
LONG CSerial::Purge() { // Reset error state m_lLastError = ERROR_SUCCESS; // Check if the device is open if (m_hFile == 0) { // Set the internal error code m_lLastError = ERROR_INVALID_HANDLE; // Issue an error and quit _RPTF0(_CRT_WARN,"CSerial::Purge - Device is not opened\n"); return m_lLastError; } if (!::PurgeComm(m_hFile, PURGE_TXCLEAR | PURGE_RXCLEAR)) { // Set the internal error code m_lLastError = ::GetLastError(); _RPTF0(_CRT_WARN,"CSerial::Purge - Overlapped completed without result\n"); } // Return successfully return m_lLastError; }
STDAPI DllUnregisterServer(void) { HRESULT hr; hr = CShellNSE::UnregisterProperties(g_hInst, CLSID_ShellFolderProperties); if( FAILED(hr) ) { _RPTF0(_CRT_WARN, "UnregisterProperties failed\n"); return FALSE; } hr = CShellNSE::UnregisterServer(g_hInst, CLSID_ShellFolderNameSpace); if( FAILED(hr) ) { _RPTF0(_CRT_WARN, "UnregisterServer failed\n"); return E_FAIL; } if( !CGoogleDS::UnregisterPlugin() ) { _RPTF0(_CRT_WARN, "CGoogleDS::UnregisterPlugin() failed\n"); } ::CoFreeUnusedLibraries(); return hr; }
CSerial::EError CSerial::GetError (void) { // Reset error state m_lLastError = ERROR_SUCCESS; // Check if the device is open if (m_hFile == 0) { // Set the internal error code m_lLastError = ERROR_INVALID_HANDLE; // Issue an error and quit _RPTF0(_CRT_WARN,"CSerial::GetError - Device is not opened\n"); return EErrorUnknown; } // Obtain COM status DWORD dwErrors = 0; if (!::ClearCommError(m_hFile,&dwErrors,0)) { // Set the internal error code m_lLastError = ::GetLastError(); // Issue an error and quit _RPTF0(_CRT_WARN,"CSerial::GetError - Unable to obtain COM status\n"); return EErrorUnknown; } // Return the error return EError(dwErrors); }
BYTE CSerial::GetEventChar (void) { // Reset error state m_lLastError = ERROR_SUCCESS; // Check if the device is open if (m_hFile == 0) { // Set the internal error code m_lLastError = ERROR_INVALID_HANDLE; // Issue an error and quit _RPTF0(_CRT_WARN,"CSerial::GetEventChar - Device is not opened\n"); return 0; } // Obtain the DCB structure for the device CDCB dcb; if (!::GetCommState(m_hFile,&dcb)) { // Obtain the error code m_lLastError = ::GetLastError(); // Display a warning _RPTF0(_CRT_WARN,"CSerial::GetEventChar - Unable to obtain DCB information\n"); return 0; } // Set the new event character return BYTE(dcb.EvtChar); }
STDAPI DllRegisterServer(void) { HRESULT hr; /*if( !CSettings::SaveCurrentPath() ) { _RPTF0(_CRT_WARN, "SaveCurrentPath failed\n"); return E_FAIL; }*/ if( !CGoogleDS::RegisterPlugin() ) { _RPTF0(_CRT_WARN, "RegisterPlugin failed\n"); //return E_FAIL; } hr = CShellNSE::RegisterServer(g_hInst, CLSID_ShellFolderNameSpace); if( FAILED(hr) ) { _RPTF0(_CRT_WARN, "RegisterServer failed\n"); return E_FAIL; } hr = CShellNSE::RegisterProperties(g_hInst, CLSID_ShellFolderNameSpace, CLSID_ShellFolderProperties); if( FAILED(hr) ) { _RPTF0(_CRT_WARN, "RegisterServer failed\n"); return E_FAIL; } return hr; }
//------------------------------------------------------------------------------ /// 지정된 사이즈의 BmpFile인가를 체크한다. //------------------------------------------------------------------------------ bool CClanMarkTransfer::Check_BmpFile( HANDLE hFile, SIZE size ) { DWORD dwFileSizeHigh; DWORD dwFileSizeLow = GetFileSize( hFile, &dwFileSizeHigh ); if( dwFileSizeLow == INVALID_FILE_SIZE || dwFileSizeHigh != 0 ) { _RPTF1( _CRT_ASSERT,"GetFileSize Error(%d)", GetLastError() ); g_itMGR.OpenMsgBox("CClanMarkTransfer::Check_BmpFile-GetFileSize Error" ); return false; } ///BMP 화일 최소 사이즈( 헤더사이즈) Check const int BmpHeaderSize = sizeof( BITMAPFILEHEADER ) + sizeof( BITMAPINFOHEADER ); if( dwFileSizeLow < BmpHeaderSize ) { _RPTF1( _CRT_ASSERT,"File Size is too small(%d)", dwFileSizeLow ); g_itMGR.OpenMsgBox( CStr::Printf("%s %s",STR_CLANMARK_INVALID_FORMAT ,STR_CLANMARK_HELP_HOMEPAGE )); return false; } ///File Load BYTE header_buffer[BmpHeaderSize]; DWORD NumberOfBytesRead; if( FALSE == ReadFile( hFile, header_buffer, BmpHeaderSize, &NumberOfBytesRead, NULL ) ) { _RPTF0( _CRT_ASSERT,"ReadFile Error:BmpFile" ); g_itMGR.OpenMsgBox( "CClanMarkTransfer::Check_BmpFile-ReadFile Error" ); return false; } /// 2. 포맷이 맞는지 체크 BITMAPFILEHEADER* BitmapFileHeader = (BITMAPFILEHEADER*)header_buffer; BITMAPINFOHEADER* BitmapInfoHeader = (BITMAPINFOHEADER*)&(header_buffer[ sizeof( BITMAPFILEHEADER) ]); const WORD DIB_HEADER_MARKER = 0x4D42; if( BitmapFileHeader->bfType != DIB_HEADER_MARKER ) { _RPTF0( _CRT_ASSERT,"Invalid Bmp Format File" ); g_itMGR.OpenMsgBox( CStr::Printf("%s %s",STR_CLANMARK_INVALID_FORMAT,STR_CLANMARK_HELP_HOMEPAGE ) ); return false; } if( size.cx > 0 && size.cy > 0 ) { if( BitmapInfoHeader->biWidth != size.cx || BitmapInfoHeader->biHeight != size.cy ) { _RPTF2( _CRT_ASSERT,"Invalid Canvas Size( Require - Width:20,Height:20 ) ,File (Width:%d, Height:%d)", BitmapInfoHeader->biWidth, BitmapInfoHeader->biHeight ); g_itMGR.OpenMsgBox( CStr::Printf("%s %s",STR_CLANMARK_INVALID_SIZE ,STR_CLANMARK_HELP_HOMEPAGE )); return false; } } return true; }
LONG CSerial::SetEventChar (BYTE bEventChar, bool fAdjustMask) { // Reset error state m_lLastError = ERROR_SUCCESS; // Check if the device is open if (m_hFile == 0) { // Set the internal error code m_lLastError = ERROR_INVALID_HANDLE; // Issue an error and quit _RPTF0(_CRT_WARN,"CSerial::SetEventChar - Device is not opened\n"); return m_lLastError; } // Obtain the DCB structure for the device CDCB dcb; if (!::GetCommState(m_hFile,&dcb)) { // Obtain the error code m_lLastError = ::GetLastError(); // Display a warning _RPTF0(_CRT_WARN,"CSerial::SetEventChar - Unable to obtain DCB information\n"); return m_lLastError; } // Set the new event character dcb.EvtChar = char(bEventChar); // Adjust the event mask, to make sure the event will be received if (fAdjustMask) { // Enable 'receive event character' event. Note that this // will generate an EEventNone if there is an asynchronous // WaitCommEvent pending. SetMask(GetEventMask() | EEventRcvEv); } // Set the new DCB structure if (!::SetCommState(m_hFile,&dcb)) { // Obtain the error code m_lLastError = ::GetLastError(); // Display a warning _RPTF0(_CRT_WARN,"CSerial::SetEventChar - Unable to set DCB information\n"); return m_lLastError; } // Return successful return m_lLastError; }
LONG CSerial::Setup (EBaudrate eBaudrate, EDataBits eDataBits, EParity eParity, EStopBits eStopBits) { // Reset error state m_lLastError = ERROR_SUCCESS; // Check if the device is open if (m_hFile == 0) { // Set the internal error code m_lLastError = ERROR_INVALID_HANDLE; // Issue an error and quit _RPTF0(_CRT_WARN,"CSerial::Setup - Device is not opened\n"); return m_lLastError; } // Obtain the DCB structure for the device CDCB dcb; if (!::GetCommState(m_hFile,&dcb)) { // Obtain the error code m_lLastError = :: GetLastError(); // Display a warning _RPTF0(_CRT_WARN,"CSerial::Setup - Unable to obtain DCB information\n"); return m_lLastError; } // Set the new data dcb.BaudRate = DWORD(eBaudrate); dcb.ByteSize = BYTE(eDataBits); dcb.Parity = BYTE(eParity); dcb.StopBits = BYTE(eStopBits); // Determine if parity is used dcb.fParity = (eParity != EParNone); // Set the new DCB structure if (!::SetCommState(m_hFile,&dcb)) { // Obtain the error code m_lLastError = ::GetLastError(); // Display a warning _RPTF0(_CRT_WARN,"CSerial::Setup - Unable to set DCB information\n"); return m_lLastError; } // Return successful return m_lLastError; }
LONG CSerialEx::StartListener (void) { // Check if the watcher thread was already running if (m_hThread == 0) { // Make sure the thread has stopped _ASSERTE(!m_fStopping); // Start the watcher thread DWORD dwThreadId = 0; m_hThread = ::CreateThread(0,0,ThreadProc,LPVOID(this),0,&dwThreadId); if (m_hThread == 0) { // Display a warning _RPTF0(_CRT_WARN, "CSerialEx::StartListener - Unable to start COMM watcher thread\n"); // Set the error code and exit m_lLastError = ::GetLastError(); return m_lLastError; } } // Return the error m_lLastError = ERROR_SUCCESS; return m_lLastError; }
void CNetwork::StopThread() { if ( m_hThread == NULL ) return; m_bThread = FALSE; m_pWakeup.SetEvent(); for ( int nAttempt = 50 ; nAttempt > 0 ; nAttempt-- ) { DWORD nCode; if ( ! GetExitCodeThread( m_hThread, &nCode ) ) break; if ( nCode != STILL_ACTIVE ) break; Sleep( 100 ); MSG msg; while ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } } if ( nAttempt == 0 ) { TerminateThread( m_hThread, 0 ); _RPTF0(_CRT_WARN, _T("WARNING: Terminating CNetwork thread.\n")); Sleep( 100 ); } m_hThread = NULL; }
bool Data_EnemyParam::EncodeCsv(){ if(!LoadDataFromCsv()) return false; // VectorListのデータ部分を書き出す // ファイルに書き出す TCHAR fileName[MAX_PATH]; std::basic_ofstream<TCHAR> fout; // 暗号化のためのコピーを行うバッファ // (2014年夏コミでは暗号化を行わない DATA_ENEMYPARAM_EACH_DATA copiedData; Data_EnemyParam_Each* dataPtr; // 人形の数だけデータの書き出しを行う DWORD length = enemyList.GetSize(); // データの個数を最初に書き出す for(DWORD n=0; n<length; n++){ // 実体を返す dataPtr = enemyList.GetPointerByIndex(n); copiedData = dataPtr->data; wsprintf(fileName, DATFILE_ENEMYPARAM, n); fout.open(fileName, std::ios::out|std::ios::binary|std::ios::trunc); if(!fout){ _RPTF0(_CRT_WARN, "書き出し用ファイルが開けませんでした。\n"); return false; } fout.write((char*)&copiedData, sizeof(DATA_ENEMYPARAM_EACH_DATA)); fout.close(); fout.clear(); } return true; }
bool Data_DollParam::LoadDataFromDat(){ // ファイルを開く std::basic_ifstream<TCHAR> fin; fin.open(DATFILE_DOLLPARAM, std::ios::in|std::ios::binary); if(!fin){ _RPTF0(_CRT_WARN, "読み込み用ファイルが開けませんでした。\n"); return false; } TCHAR copiedTypeName[DOLL_TYPENAME_BYTES]; LEVELTOPARAM copiedLTP; LEVELUPBONUS copiedBonus; // 人形の数だけデータの書き出しを行う for(int n=0; n<DOLL_TYPE_MAX; n++){ fin.read((char*)copiedTypeName, sizeof(TCHAR)*DOLL_TYPENAME_BYTES); dollList[n].SetName(copiedTypeName); for(int i=0; i<DOLL_PARAM_MAX; i++){ fin.read((char*)&copiedLTP, sizeof(LEVELTOPARAM)); dollList[n].SetLvToP(i, copiedLTP); } for(int i=0; i<DOLL_LEVEL_MAX; i++){ fin.read((char*)&copiedBonus, sizeof(LEVELUPBONUS)); dollList[n].SetLvBonus(i, copiedBonus); } } // 読み込み終了 fin.close(); return true; }
//-------------------------------------------------------------------------------- /// 3. Memory에 로딩하면서 바로 임시 화일에 저장 //-------------------------------------------------------------------------------- bool CClanMarkTransfer::WriteToZipFile( const char* TempZipFileName, HANDLE hBmpFile, DWORD* pdwNumberOfBytesRead ) { gzFile zfp; if( (zfp = gzopen( TempZipFileName, "wb9")) == NULL ) { _RPTF0( _CRT_ASSERT,"Open Error, Temporary zip file" ); g_itMGR.OpenMsgBox( "CClanMarkTransfer::WriteToZipFile-gzopen Error"); return false; } BYTE read_buffer[256]; SetFilePointer( hBmpFile, 0, 0, FILE_BEGIN );//File Pointer앞으로 이동 while( ReadFile( hBmpFile,read_buffer, sizeof(read_buffer),pdwNumberOfBytesRead,NULL ) ) { if( *pdwNumberOfBytesRead == 0 )///EOF break; if (gzwrite(zfp, read_buffer, *pdwNumberOfBytesRead ) < 0) { int lerrno = 0; g_itMGR.OpenMsgBox( "CClanMarkTransfer::WriteToZipFile-gzwrite Error"); _RPTF1( _CRT_ASSERT,"gzwrite error:%s",gzerror(zfp,&lerrno )); gzclose(zfp); return false; } } gzclose(zfp); return true; }
//-------------------------------------------------------------------------------- /// 2. CRC를 구한다. //-------------------------------------------------------------------------------- bool CClanMarkTransfer::GetImageFileCRC( HANDLE hBmpFile, WORD* pBmpCRC16, DWORD* pdwNumberOfBytesRead, DWORD* pdwFileSizeHigh, DWORD* pdwFileSizeLow ) { if( pdwFileSizeLow == NULL || pdwFileSizeHigh == NULL ) return false; *pdwFileSizeLow = GetFileSize( hBmpFile, pdwFileSizeHigh ); if( *pdwFileSizeLow == INVALID_FILE_SIZE || *pdwFileSizeHigh != 0 ) { _RPTF1( _CRT_ASSERT,"GetFileSize Error(%d)", GetLastError() ); g_itMGR.OpenMsgBox( "CClanMarkTransfer::GetImageFileCRC-GetFileSize Error" ); return false; } BYTE* bmp_buffer = new BYTE[*pdwFileSizeLow]; SetFilePointer( hBmpFile, 0, 0, FILE_BEGIN ); if( FALSE == ReadFile( hBmpFile, bmp_buffer, *pdwFileSizeLow, pdwNumberOfBytesRead, NULL ) ) { g_itMGR.OpenMsgBox( "CClanMarkTransfer::GetImageFileCRC-ReadFile" ); _RPTF0( _CRT_ASSERT,"ReadFile Error:BmpFile" ); delete []bmp_buffer; return false; } assert( *pdwFileSizeLow == *pdwNumberOfBytesRead ); *pBmpCRC16 = classCRC::DataCRC16( bmp_buffer, *pdwFileSizeLow ); delete []bmp_buffer; return true; }
/** * @brief Check if any of filefilter rules match to filename. * * @param [in] szFileName Filename to test. * @return TRUE unless we're suppressing this file by filter */ BOOL FileFilterHelper::includeFile(LPCTSTR szFileName) { if (m_bUseMask) { if (m_pMaskFilter == NULL) { _RPTF0(_CRT_ERROR, "Use mask set, but no filter rules for mask!"); return TRUE; } // preprend a backslash if there is none CString strFileName = szFileName; strFileName.MakeLower(); if (strFileName[0] != _T('\\')) strFileName = _T('\\') + strFileName; // append a point if there is no extension if (strFileName.Find(_T('.')) == -1) strFileName = strFileName + _T('.'); char * name_utf = UCS2UTF8_ConvertToUtf8(strFileName); bool match = m_pMaskFilter->Match(strlen(name_utf), name_utf); UCS2UTF8_Dealloc(name_utf); return match; } else { if (!m_fileFilterMgr || !m_currentFilter) return TRUE; return m_fileFilterMgr->TestFileNameAgainstFilter(m_currentFilter, szFileName); } }
LONG CSerial::Close (void) { // Reset error state m_lLastError = ERROR_SUCCESS; // If the device is already closed, // then we don't need to do anything. if (m_hFile == 0) { // Display a warning _RPTF0(_CRT_WARN,"CSerial::Close - Method called when device is not open\n"); return m_lLastError; } #ifndef SERIAL_NO_OVERLAPPED // Free event handle if (m_hevtOverlapped) { ::CloseHandle(m_hevtOverlapped); m_hevtOverlapped = 0; } #endif // Close COM port ::CloseHandle(m_hFile); m_hFile = 0; // Return successful return m_lLastError; }
void COpenView::OnButton(int index) { String s; String sfolder; UpdateData(TRUE); PATH_EXISTENCE existence = paths_DoesPathExist(m_strPath[index], IsArchiveFile); switch (existence) { case IS_EXISTING_DIR: sfolder = m_strPath[index]; break; case IS_EXISTING_FILE: sfolder = paths_GetPathOnly(m_strPath[index]); break; case DOES_NOT_EXIST: // Do nothing, empty foldername will be passed to dialog break; default: _RPTF0(_CRT_ERROR, "Invalid return value from paths_DoesPathExist()"); break; } if (SelectFileOrFolder(GetSafeHwnd(), s, sfolder.c_str())) { m_strPath[index] = s; m_strBrowsePath[index] = s; UpdateData(FALSE); UpdateButtonStates(); } }
// 体験版のデータをロードする。 bool AliceFile_141126::Load(){ // ファイルを開く std::basic_ifstream<TCHAR> fin; fin.open(ALICEFILE_141126_FILENAME, std::ios::in|std::ios::binary); if(!fin){ _RPTF0(_CRT_WARN, "読み込み用ファイルが開けませんでした。\n"); return false; } // ファイルから内容を読み込む ALICEFILE_141126_DATA loadedData; int dataSize = sizeof(ALICEFILE_141126_DATA)*sizeof(char); fin.read((char*)&loadedData, dataSize); if(!fin){ _RPTF0(_CRT_WARN, "ファイルの内容が読み込めませんでした。\n"); return false; } // 復号 void* pData = static_cast<void*>(&loadedData); BYTE* byte_casted_data = static_cast<BYTE*>(pData); // 上の行と合わせて無理やりバイト列に変換 // データに対して直接排他的論理和を行う int pos; TCHAR code[ALICEFILE_141126_XORCODE_LENGTH+1]; strcpy_s(code, ALICEFILE_141126_XORCODE_LENGTH+1, ALICEFILE_141126_XORCODE); TCHAR code2[ALICEFILE_141126_XORCODE2_LENGTH+1]; strcpy_s(code2, ALICEFILE_141126_XORCODE2_LENGTH+1, ALICEFILE_141126_XORCODE2); for(int i=0; i<dataSize; i++){ pos = ((i+3)%strlen(ALICEFILE_141126_XORCODE)); // ちょっとずらした位置で暗号化 byte_casted_data[i] = byte_casted_data[i]^code[pos]; pos = ((i+7)%strlen(ALICEFILE_141126_XORCODE2)); byte_casted_data[i] = byte_casted_data[i]^code2[pos]; } // 復号後のデータをコピーする data = loadedData; // 読み込み終了 fin.close(); // データをグローバル変数にコピー return CopyToData(); return true; }
// 体験版のデータを保存する。 bool AliceFile_141126::Save(){ // 各レコードからデータを取ってくる data.dAliceInfo = r_aliceInfo.GetData(); for(int n=0; n<RECORD_DANGEON_NUM; n++){ data.dDangeon[n] = r_dangeon.GetData(n); } data.dItem = r_item.GetData(); for(int n=0; n<MAX_DOLLS; n++){ data.dDolls[n] = r_aliceDoll.GetEachData(n); } for(int n=0; n<MAX_CASKETS; n++){ data.dCaskets[n] = r_casket.GetEachData(n); } // BGMとSE data.BGM = g_cfg.BGM; data.SE = g_cfg.SE; data.dollID = gr_others.GetNextDollID(); // ファイルを開く std::basic_ofstream<TCHAR> fout; fout.open(ALICEFILE_141126_FILENAME, std::ios::out|std::ios::binary|std::ios::trunc); if(!fout){ _RPTF0(_CRT_WARN, "書き出し用ファイルが開けませんでした。\n"); return false; } // 現在のデータのコピーを取り、暗号化 ALICEFILE_141126_DATA copiedData; copiedData = data; int dataSize = sizeof(ALICEFILE_141126_DATA)*sizeof(char); void* pData = static_cast<void*>(&copiedData); BYTE* byte_casted_data = static_cast<BYTE*>(pData); // 上の行と合わせて無理やりバイト列に変換 // データに対して直接排他的論理和を行う int pos; TCHAR code[ALICEFILE_141126_XORCODE_LENGTH+1]; strcpy_s(code, ALICEFILE_141126_XORCODE_LENGTH+1, ALICEFILE_141126_XORCODE); TCHAR code2[ALICEFILE_141126_XORCODE2_LENGTH+1]; strcpy_s(code2, ALICEFILE_141126_XORCODE2_LENGTH+1, ALICEFILE_141126_XORCODE2); for(int i=0; i<dataSize; i++){ pos = ((i+3)%strlen(ALICEFILE_141126_XORCODE)); // ちょっとずらした位置で暗号化 byte_casted_data[i] = byte_casted_data[i]^code[pos]; pos = ((i+7)%strlen(ALICEFILE_141126_XORCODE2)); byte_casted_data[i] = byte_casted_data[i]^code2[pos]; } // 実際の書き出し fout.write((char*)&copiedData, dataSize); // 書き出し終了 fout.close(); return true; }
void gRelease(int cls) { if(ENUM_CLASSES_LENGTH <= cls) { _RPTF0(_CRT_ERROR, "gRelease\n"); } g_DllRefCount--; g_references[cls]--; }
void gAddRef(int cls) { if(ENUM_CLASSES_LENGTH <= cls) { _RPTF0(_CRT_ERROR, "gAddRef\n"); } g_DllRefCount++; g_references[cls]++; }
bool Data_EnemyDraw::EncodeCsv(){ if(!LoadDataFromCsv()) return false; // VectorListのデータ部分を書き出す // ファイルに書き出す // ファイルを開く std::basic_ofstream<TCHAR> fout; fout.open(DATFILE_ENEMYDRAW, std::ios::out|std::ios::binary|std::ios::trunc); if(!fout){ _RPTF0(_CRT_WARN, "書き出し用ファイルが開けませんでした。\n"); return false; } // 暗号化のためのコピーを行うバッファ // (2014年夏コミでは暗号化を行わない DATA_ENEMYDRAW_DATA copiedData; DATA_ENEMYDRAW_DATA* dataPtr; // 人形の数だけデータの書き出しを行う DWORD length = drawList.GetSize(); // データの個数を最初に書き出す fout.write((char*)&length, sizeof(DWORD)); for(DWORD n=0; n<length; n++){ // 実体を返す dataPtr = drawList.GetPointerByIndex(n); copiedData = *dataPtr; fout.write((char*)&copiedData, sizeof(DATA_ENEMYDRAW_DATA)); } // 書き出し終了 fout.close(); return true; /* DWORD fileSize = 0; void* dataPtr = NULL; std::basic_ofstream<TCHAR> fout; // dataPtr = drawList.SaveToString(&fileSize); if(fileSize != 0){ // ファイルを開く fout.open(DATFILE_ENEMYDRAW, std::ios::out|std::ios::binary|std::ios::trunc); if(!fout){ _RPTF0(_CRT_WARN, "書き出し用ファイルが開けませんでした。\n"); return false; } // データを書き出す fout.write((char*)dataPtr, fileSize); // 書き出し終了 fout.close(); // 確保した領域の開放 VirtualFree(dataPtr, fileSize, MEM_DECOMMIT); } return true; */ }
CSerial::EHandshake CSerial::GetHandshaking (void) { // Reset error state m_lLastError = ERROR_SUCCESS; // Check if the device is open if (m_hFile == 0) { // Set the internal error code m_lLastError = ERROR_INVALID_HANDLE; // Issue an error and quit _RPTF0(_CRT_WARN,"CSerial::GetHandshaking - Device is not opened\n"); return EHandshakeUnknown; } // Obtain the DCB structure for the device CDCB dcb; if (!::GetCommState(m_hFile,&dcb)) { // Obtain the error code m_lLastError = ::GetLastError(); // Display a warning _RPTF0(_CRT_WARN,"CSerial::GetHandshaking - Unable to obtain DCB information\n"); return EHandshakeUnknown; } // Check if hardware handshaking is being used if ((dcb.fDtrControl == DTR_CONTROL_HANDSHAKE) && (dcb.fRtsControl == RTS_CONTROL_HANDSHAKE)) return EHandshakeHardware; // Check if software handshaking is being used if (dcb.fOutX && dcb.fInX) return EHandshakeSoftware; // No handshaking is being used return EHandshakeOff; }
CSerial::~CSerial () { // If the device is already closed, // then we don't need to do anything. if (m_hFile) { // Display a warning _RPTF0(_CRT_WARN,"CSerial::~CSerial - Serial port not closed\n"); // Close implicitly Close(); } }
CSerial::EParity CSerial::GetParity (void) { // Reset error state m_lLastError = ERROR_SUCCESS; // Check if the device is open if (m_hFile == 0) { // Set the internal error code m_lLastError = ERROR_INVALID_HANDLE; // Issue an error and quit _RPTF0(_CRT_WARN,"CSerial::GetParity - Device is not opened\n"); return EParUnknown; } // Obtain the DCB structure for the device CDCB dcb; if (!::GetCommState(m_hFile,&dcb)) { // Obtain the error code m_lLastError = ::GetLastError(); // Display a warning _RPTF0(_CRT_WARN,"CSerial::GetParity - Unable to obtain DCB information\n"); return EParUnknown; } // Check if parity is used if (!dcb.fParity) { // No parity return EParNone; } // Return the appropriate parity setting return EParity(dcb.Parity); }
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) { switch(dwReason) { case DLL_PROCESS_ATTACH: TESTHR( CoInitialize(NULL) ); g_hInst = hInstance; CSettings::GetGlobalSettings(); g_pConfigXML = new CConfigXML(); g_pViewList = new CViewList(); g_pPidlMgr = new CPidlManager(); g_pDialogList = new CDialogList(); break; case DLL_PROCESS_DETACH: _RPTF0(_CRT_WARN, "DLL_PROCESS_DETACH\n"); CSettings::SaveGlobalSettings(); if(g_pViewList) delete g_pViewList; if(g_pConfigXML) { try{ delete g_pConfigXML; }catch(...){ _RPTF0(_CRT_WARN, "Error deleting configxml\n"); } } if(g_pPidlMgr) delete g_pPidlMgr; if(g_pDialogList) delete g_pDialogList; CoUninitialize(); //_RPTF0(_CRT_WARN, "Unloaded\n"); break; } return TRUE; }
CSerialEx::~CSerialEx() { // Check if the thread handle is still there. If so, then we // didn't close the serial port. We cannot depend on the // CSerial destructor, because if it calls Close then it // won't call our overridden Close. if (m_hThread) { // Display a warning _RPTF0(_CRT_WARN, "CSerialEx::~CSerialEx - Serial port not closed\n"); // Close implicitly Close(); } }