/**
 * RawTsThread ()
 */
static void *RawTsThread(void *param)
{
  uint32_t Size = 50000;

  printf(CRB "RAWTS Thread Started" CRA);

  while(RequestStopRawTsThread == 0) 
  {
    int32_t rc;

    Size = 50000;
/*    rc = DibTsRead(CONTEXT, RawTsBufer, &Size); */
rc = 0;
/**/
    printf(CRB "Read TS: Size= %d, rc= %d" CRA, Size, rc);

    CheckTsContinuity(RawTsBufer,Size);
    SaveBufferToFile(RawTsBufer,Size);
  }

  printf(CRB "RAWTS Thread Stopped" CRA);
  RequestStopRawTsThread = 0;

  return (0);
}
Beispiel #2
0
void XLog::Flush()
{
  if (0 == m_savingqueue_size)
    return;
  m_file_date_tmp = new SYSTEMTIME();
  GetLocalTime(m_file_date_tmp);
  string sfile = m_logfilepath;
  sfile.append(m_computer_name);
  sfile.append("_");
  sfile.append(ExtractFileName(ParamStr(0)));
  sfile.append("_");
  sfile.append(FormatDate(*m_file_date_tmp));
  sfile.append(".log");

  if (!FileExists(sfile.c_str()))
  {
//      unsigned char head[2] = {0xFF,0xFE};
      SaveBufferToFile(sfile,m_savingqueue_logical,m_savingqueue_size);
  }
  else
  {
	  AppendBuf2File(sfile,m_savingqueue_logical,m_savingqueue_size);
  }
  m_savingqueue_size = 0;
}
void TemplateClassDlg::OnGenerate( wxCommandEvent& event )
{
	wxUnusedVar(event);
	wxArrayString files;
	wxString newClassName = m_textCtrlClassName->GetValue();
	wxString baseClass = m_comboxCurrentTemplate->GetValue();

	if (!wxEndsWithPathSeparator(m_projectPath))
		m_projectPath += wxFILE_SEP_PATH;

	wxString buffer = GetStringDb()->GetString( baseClass, swHeader );
	buffer.Replace( swPhClass, newClassName );
	buffer.Replace(wxT("\v"), eol[m_curEol].c_str());

	files.Add( m_projectPath + m_textCtrlHeaderFile->GetValue() );
	SaveBufferToFile( files.Item(0), buffer );

	buffer = wxString::Format( wxT( "#include \"%s\"%s%s" ), m_textCtrlHeaderFile->GetValue().c_str(), eol[m_curEol].c_str(), eol[m_curEol].c_str() );
	buffer += GetStringDb()->GetString( baseClass, swSource );
	buffer.Replace( swPhClass, newClassName );
	buffer.Replace(wxT("\v"), eol[m_curEol].c_str());

	files.Add( m_projectPath + m_textCtrlCppFile->GetValue() );
	SaveBufferToFile( files.Item(1), buffer );

	if ( !m_textCtrlVD->GetValue().IsEmpty() ) {
		// Create the Success message first, as 'files' may be altered during creation
		wxString msg;
		msg << wxString::Format( wxT( "%s%s" ), files.Item(0).c_str(), eol[m_curEol].c_str())
		<< wxString::Format( wxT( "%s%s%s" ), files.Item(1).c_str(), eol[m_curEol].c_str(), eol[m_curEol].c_str())
		<< _( "Files successfully created." );
		// We have a .cpp and an .h file, and there may well be a :src and an :include folder available
		// So try to place the files appropriately. If that fails, dump both in the selected folder
		
		bool smartAddFiles = EditorConfigST::Get()->GetOptions()->GetOptions() & OptionsConfig::Opt_SmartAddFiles;
		
		if ( (smartAddFiles && m_pManager->AddFilesToVirtualFolderIntelligently( m_textCtrlVD->GetValue(), files )) || m_pManager->AddFilesToVirtualFolder( m_textCtrlVD->GetValue(), files ) ) 
		{
			wxMessageBox(msg, _("Add template class"), wxOK|wxCENTER|wxICON_INFORMATION, this);
			EndModal(wxID_OK);
			return;
		}
	}

	wxMessageBox(_("Adding the template class failed"), _("Oops"), wxOK|wxCENTER|wxICON_WARNING, this);
	EndModal(wxID_CANCEL);	// The return value isn't actually used at present, but send Cancel on failure for future-proofing
}
Beispiel #4
0
int main(int argc, char *argv[])
{
	int error;
	char *action;
	char ch;
	BYTE readBuffer[CMOS_LENGTH];
	
	printf("CMOS Read Tool %s, Copyright (c) 2011 AMD Suzhou GPU SLT\n",VERSION);	
	if(argc>=3)
	{
		action = argv[1];
		ch = tolower(action[0]);
		switch(ch)
		{
			//-----------------------------------
			//    Read CMOS as a file
			//-----------------------------------
			case 'r':
				memset(readBuffer,0x00,CMOS_LENGTH);
				if(ReadCmosToBuffer(readBuffer)<0)
				{	
					error = 1;
					break;
				}
				DisplayByte(readBuffer);
				if(SaveBufferToFile(readBuffer,argv[2])<0)
					error = 1;
				
				break;
			//---------------------------------
			//     Verify CMOS from a file
			//---------------------------------	
			case 'v':
				memset(readBuffer,0x00,CMOS_LENGTH);
				if(ReadCmosToBuffer(readBuffer)<0)
				{	
					error = 1;
					break;
				}
				if(VerifyCmosWithFile(readBuffer,argv[2])<0)
					error = 1;
				break;
			/*	
			case 'w':
				WriteCmosFromFile(argv[2]);
				break;
			*/
			default:
				error = 1;
				ShowHelp();
				break;				
		}	
	}
	else
	{
		ShowHelp();
		error = 1;
	}
	return error;

}
Beispiel #5
0
void __cdecl ExtractAllFilesThread (void *hwndDlg)
{
	int fileNo;
	BOOL bSuccess = FALSE;
	char packageFile [TC_MAX_PATH];

	InvalidateRect (GetDlgItem (GetParent (hwndDlg), IDD_INSTL_DLG), NULL, TRUE);

	ClearLogWindow (hwndDlg);

	GetModuleFileName (NULL, packageFile, sizeof (packageFile));

	if (!(bSuccess = SelfExtractInMemory (packageFile)))
		goto eaf_end;

	if (mkfulldir (DestExtractPath, TRUE) != 0)
	{
		if (mkfulldir (DestExtractPath, FALSE) != 0)
		{
			wchar_t szTmp[TC_MAX_PATH];

			handleWin32Error (hwndDlg);
			wsprintfW (szTmp, GetString ("CANT_CREATE_FOLDER"), DestExtractPath);
			MessageBoxW (hwndDlg, szTmp, lpszTitle, MB_ICONHAND);
			bSuccess = FALSE;
			goto eaf_end;
		}
	}

	for (fileNo = 0; fileNo < NBR_COMPRESSED_FILES; fileNo++)
	{
		char fileName [TC_MAX_PATH] = {0};
		char filePath [TC_MAX_PATH] = {0};

		// Filename
		strncpy (fileName, Decompressed_Files[fileNo].fileName, Decompressed_Files[fileNo].fileNameLength);
		fileName [Decompressed_Files[fileNo].fileNameLength] = 0;
		strcpy (filePath, DestExtractPath);
		strcat (filePath, fileName);

		StatusMessageParam (hwndDlg, "EXTRACTING_VERB", filePath);

		// Write the file
		if (!SaveBufferToFile (
			Decompressed_Files[fileNo].fileContent,
			filePath,
			Decompressed_Files[fileNo].fileLength,
			FALSE))
		{
			wchar_t szTmp[512];

			_snwprintf (szTmp, sizeof (szTmp) / 2, GetString ("CANNOT_WRITE_FILE_X"), filePath);
			MessageBoxW (hwndDlg, szTmp, lpszTitle, MB_ICONERROR | MB_SETFOREGROUND | MB_TOPMOST);
			bSuccess = FALSE;
			goto eaf_end;
		}
		UpdateProgressBarProc ((int) (100 * ((float) fileNo / NBR_COMPRESSED_FILES)));
	}

eaf_end:
	FreeAllFileBuffers();

	if (bSuccess)
		PostMessage (MainDlg, TC_APPMSG_EXTRACTION_SUCCESS, 0, 0);
	else
		PostMessage (MainDlg, TC_APPMSG_EXTRACTION_FAILURE, 0, 0);
}
Beispiel #6
0
BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
{
	int i, x;
	unsigned char inputFile [TC_MAX_PATH];
	unsigned char outputFile [TC_MAX_PATH];
	unsigned char szTmpFilePath [TC_MAX_PATH];
	unsigned char szTmp32bit [4] = {0};
	unsigned char *szTmp32bitPtr = szTmp32bit;
	unsigned char *buffer = NULL, *compressedBuffer = NULL;
	unsigned char *bufIndex = NULL;
	char tmpStr [2048];
	int bufLen = 0, compressedDataLen = 0, uncompressedDataLen = 0;

	x = strlen (szDestDir);
	if (x < 2)
		return FALSE;

	if (szDestDir[x - 1] != '\\')
		strcat (szDestDir, "\\");

	GetModuleFileName (NULL, inputFile, sizeof (inputFile));

	strcpy (outputFile, szDestDir);
	strncat (outputFile, OutputPackageFile, sizeof (outputFile) - strlen (outputFile) - 1);

	// Clone 'TrueCrypt Setup.exe' to create the base of the new self-extracting archive

	if (!TCCopyFile (inputFile, outputFile))
	{
		handleWin32Error (hwndDlg);
		PkgError ("Cannot copy 'TrueCrypt Setup.exe' to the package");
		return FALSE;
	}

	// Determine the buffer size needed for all the files and meta data and check if all required files exist

	bufLen = 0;

	for (i = 0; i < sizeof (szCompressedFiles) / sizeof (szCompressedFiles[0]); i++)
	{
		_snprintf (szTmpFilePath, sizeof(szTmpFilePath), "%s%s", szDestDir, szCompressedFiles[i]);

		if (!FileExists (szTmpFilePath))
		{
			char tmpstr [1000];

			_snprintf (tmpstr, sizeof(tmpstr), "File not found:\n\n'%s'", szTmpFilePath);
			remove (outputFile);
			PkgError (tmpstr);
			return FALSE;
		}

		bufLen += (int) GetFileSize64 (szTmpFilePath);

		bufLen += 2;					// 16-bit filename length
		bufLen += strlen(szCompressedFiles[i]);	// Filename
		bufLen += 4;					// CRC-32
		bufLen += 4;					// 32-bit file length
	}

	buffer = malloc (bufLen + 524288);	// + 512K reserve 
	if (buffer == NULL)
	{
		PkgError ("Cannot allocate memory for uncompressed data");
		remove (outputFile);
		return FALSE;
	}


	// Write the start marker
	if (!SaveBufferToFile (MAG_START_MARKER, outputFile, strlen (MAG_START_MARKER), TRUE))
	{
		PkgError ("Cannot write the start marker");
		remove (outputFile);
		return FALSE;
	}


	bufIndex = buffer;

	// Copy all required files and their meta data to the buffer
	for (i = 0; i < sizeof (szCompressedFiles) / sizeof (szCompressedFiles[0]); i++)
	{
		DWORD tmpFileSize;
		unsigned char *tmpBuffer;

		_snprintf (szTmpFilePath, sizeof(szTmpFilePath), "%s%s", szDestDir, szCompressedFiles[i]);

		tmpBuffer = LoadFile (szTmpFilePath, &tmpFileSize);

		if (tmpBuffer == NULL)
		{
			char tmpstr [1000];

			free (tmpBuffer);
			_snprintf (tmpstr, sizeof(tmpstr), "Cannot load file \n'%s'", szTmpFilePath);
			remove (outputFile);
			PkgError (tmpstr);
			goto msep_err;
		}

		// Copy the filename length to the main buffer
		mputWord (bufIndex, (WORD) strlen(szCompressedFiles[i]));

		// Copy the filename to the main buffer
		memcpy (bufIndex, szCompressedFiles[i], strlen(szCompressedFiles[i]));
		bufIndex += strlen(szCompressedFiles[i]);

		// Compute CRC-32 hash of the uncompressed file and copy it to the main buffer
		mputLong (bufIndex, GetCrc32 (tmpBuffer, tmpFileSize));

		// Copy the file length to the main buffer
		mputLong (bufIndex, (unsigned __int32) tmpFileSize);

		// Copy the file contents to the main buffer
		memcpy (bufIndex, tmpBuffer, tmpFileSize);
		bufIndex += tmpFileSize;

		free (tmpBuffer);
	}

	// Calculate the total size of the uncompressed data
	uncompressedDataLen = (int) (bufIndex - buffer);

	// Write total size of the uncompressed data
	szTmp32bitPtr = szTmp32bit;
	mputLong (szTmp32bitPtr, (unsigned __int32) uncompressedDataLen);
	if (!SaveBufferToFile (szTmp32bit, outputFile, sizeof (szTmp32bit), TRUE))
	{
		remove (outputFile);
		PkgError ("Cannot write the total size of the uncompressed data");
		return FALSE;
	}

	// Compress all the files and meta data in the buffer to create a solid archive

	compressedBuffer = malloc (uncompressedDataLen + 524288);	// + 512K reserve
	if (compressedBuffer == NULL)
	{
		remove (outputFile);
		PkgError ("Cannot allocate memory for compressed data");
		return FALSE;
	}

	compressedDataLen = CompressBuffer (compressedBuffer, buffer, uncompressedDataLen);
	if (compressedDataLen <= 0)
	{
		remove (outputFile);
		PkgError ("Failed to compress the data");
		return FALSE;
	}

	free (buffer);

	// Write the total size of the compressed data
	szTmp32bitPtr = szTmp32bit;
	mputLong (szTmp32bitPtr, (unsigned __int32) compressedDataLen);
	if (!SaveBufferToFile (szTmp32bit, outputFile, sizeof (szTmp32bit), TRUE))
	{
		remove (outputFile);
		PkgError ("Cannot write the total size of the compressed data");
		return FALSE;
	}

	// Write the compressed data
	if (!SaveBufferToFile (compressedBuffer, outputFile, compressedDataLen, TRUE))
	{
		remove (outputFile);
		PkgError ("Cannot write compressed data to the package");
		return FALSE;
	}

	// Write the end marker
	if (!SaveBufferToFile (MagEndMarker, outputFile, strlen (MagEndMarker), TRUE))
	{
		remove (outputFile);
		PkgError ("Cannot write the end marker");
		return FALSE;
	}

	free (compressedBuffer);

	// Compute and write CRC-32 hash of the entire package
	{
		DWORD tmpFileSize;
		char *tmpBuffer;

		tmpBuffer = LoadFile (outputFile, &tmpFileSize);

		if (tmpBuffer == NULL)
		{
			handleWin32Error (hwndDlg);
			remove (outputFile);
			PkgError ("Cannot load the package to compute CRC");
			return FALSE;
		}

		// Zero all bytes that change when the exe is digitally signed (except appended blocks).
		WipeSignatureAreas (tmpBuffer);

		szTmp32bitPtr = szTmp32bit;
		mputLong (szTmp32bitPtr, GetCrc32 (tmpBuffer, tmpFileSize));
		if (!SaveBufferToFile (szTmp32bit, outputFile, sizeof (szTmp32bit), TRUE))
		{
			remove (outputFile);
			PkgError ("Cannot write the total size of the compressed data");
			return FALSE;
		}

		free (tmpBuffer);
	}

	sprintf (tmpStr, "Self-extracting package successfully created (%s)", outputFile);
	PkgInfo (tmpStr);
	return TRUE;

msep_err:
	free (buffer);
	free (compressedBuffer);
	return FALSE;
}