示例#1
0
HRESULT CHdmvClipInfo::ReadInfo(LPCTSTR strFile)
{
    m_bIsHdmv = false;
    m_hFile = CreateFile(strFile, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
                         OPEN_EXISTING, FILE_ATTRIBUTE_READONLY | FILE_FLAG_SEQUENTIAL_SCAN, NULL);

    if (m_hFile != INVALID_HANDLE_VALUE) {
        BYTE Buff[100];
        ReadBuffer(Buff, 4);
        if (memcmp(Buff, "HDMV", 4)) {
            return CloseFile(VFW_E_INVALID_FILE_FORMAT);
        }

        ReadBuffer(Buff, 4);
        if ((memcmp(Buff, "0200", 4) != 0) && (memcmp(Buff, "0100", 4) != 0)) {
            return CloseFile(VFW_E_INVALID_FILE_FORMAT);
        }

        SequenceInfo_start_address = ReadDword();
        ProgramInfo_start_address  = ReadDword();

        ReadProgramInfo();

        m_bIsHdmv = true;

        return CloseFile(S_OK);
    }

    return AmHresultFromWin32(GetLastError());
}
示例#2
0
void	DumpHeap(void)
{
	uint32	free_list_ptr = *(uint32*)(&corehelp->heap_free_list_ptr);
	uint32	alloc_list_ptr = *(uint32*)(&corehelp->heap_alloc_list_ptr);
	struct block_t *free_blk = (struct block_t*)ReadDword(free_list_ptr);
	struct block_t *alloc_blk = (struct block_t*)ReadDword(alloc_list_ptr);

	printf("free_list  = %08x -> %08x\n", free_list_ptr, (uint32)free_blk);
	printf("alloc_list = %08x -> %08x\n", alloc_list_ptr, (uint32)alloc_blk);

	while (1)
	{
		if (free_blk && (free_blk < alloc_blk))
		{
			DumpBlock("free ", free_blk);
			free_blk = (struct block_t*)ReadDword((uint32)&free_blk->next);
		}
		else if (alloc_blk)
		{
			DumpBlock("alloc", alloc_blk);
			alloc_blk = (struct block_t*)ReadDword((uint32)&alloc_blk->next);
		}
		else
		{
			break;
		}
	}



//	DumpMemory(0xf1000000, 16384);

}
示例#3
0
void CMsregPacketCatalogOrderRequest::ReadDataFromFile(CFile& cfFile, DWORD& dwChecksum)
{
	CString csKey;
	CString csValue;

	TRY
	{
		// Read inherited data.
		CMsregPacket::ReadDataFromFile(cfFile, dwChecksum);

		// Read the product name.
		m_csProductName = ReadString(cfFile, dwChecksum);

		// Read the field count.
		DWORD dwFields = ReadDword(cfFile, dwChecksum);

		// Read Fields.
		DeleteAllFields();
		for (DWORD i = 0; i < dwFields; i++)
		{
			csKey = ReadString(cfFile, dwChecksum);
			csValue = ReadString(cfFile, dwChecksum);
			AddField(csKey, csValue);
		}
		
		// Read the tax.
		m_dwTax = ReadDword(cfFile, dwChecksum);
		
		// Read the shipping.
		m_dwShipping = ReadDword(cfFile, dwChecksum);
		
		// Read the total.
		m_dwTotal = ReadDword(cfFile, dwChecksum);
		
		// Read the offer code.
		m_csOfferCode = ReadString(cfFile, dwChecksum);
		
		// Read the request code.
		m_csRequestCode = ReadString(cfFile, dwChecksum);
		
		// Read the line items.
		m_LineItems.ReadDataFromFile(cfFile, dwChecksum);
	}
	CATCH_ALL(e)
	{
		csKey.Empty();
		csValue.Empty();
		THROW_LAST();
	}
	END_CATCH_ALL
}
示例#4
0
static void	DumpBlock(const char *type, struct block_t *blk)
{
	uint32 size = (ReadDword((uint32)&blk->size) - sizeof(*blk) - sizeof(uint32)) & ~7;
	uint32 seq_id = ReadDword((uint32)&blk->seq_id);
	uint32 line = ReadDword((uint32)&blk->line);
	char *file = DupString(ReadDword((uint32)&blk->file));
	char *func = DupString(ReadDword((uint32)&blk->func));
	uint32 ptr = (uint32)blk + sizeof(*blk);

	printf("%s %08x = seq:%5d, size:%5d, %-30.30s (%4d) %s\n",
		type, ptr, seq_id, size, func, line, basename(file));

	free(file);
	free(func);
}
示例#5
0
void CMsregPacketRegistrationRequest::ReadDataFromFile(CFile& cfFile, DWORD& dwChecksum)
{
	CString csKey;
	CString csValue;

	TRY
	{
		// Read inherited data.
		CMsregPacket::ReadDataFromFile(cfFile, dwChecksum);

		// Read the product name.
		m_csProductName = ReadString(cfFile, dwChecksum);

		// Read the field count.
		DWORD dwFields = ReadDword(cfFile, dwChecksum);

		// Read Fields.
		DeleteAllFields();
		for (DWORD i = 0; i < dwFields; i++)
		{
			csKey = ReadString(cfFile, dwChecksum);
			csValue = ReadString(cfFile, dwChecksum);
			AddField(csKey, csValue);
		}
	}
	CATCH_ALL(e)
	{
		csKey.Empty();
		csValue.Empty();
		THROW_LAST();
	}
	END_CATCH_ALL
}
示例#6
0
void CMsregPacketProductInformationResponse::ReadDataFromFile(CFile& cfFile, DWORD& dwChecksum)
{
	// Read inherited data.
	CMsregPacket::ReadDataFromFile(cfFile, dwChecksum);

	// Read the product name.
	m_csProductName = ReadString(cfFile, dwChecksum);

	// Read the result value.
	m_dwResult = ReadDword(cfFile, dwChecksum);

	// Read the message (normally empty if successful).
	m_csMessage = ReadString(cfFile, dwChecksum);
	
	// Read the invoice number.
	m_dwInvoiceNumber = ReadDword(cfFile, dwChecksum);
}
示例#7
0
void CPipeServer::RvaMap()
{
	void *image=(void *)ReadQword();
	UINT32 offset=ReadDword();
	void *result=mono_image_rva_map(image, offset);

	WriteQword((UINT_PTR)result);
}
示例#8
0
文件: trace.c 项目: chunhualiu/OpenNT
VOID
TraceControl(
    IN HANDLE CurrentProcess,
    IN HANDLE CurrentThread,
    IN LPSTR ArgumentString
    )
/*++

Routine Description:

    This routine dumps LDT selectors.  The selectors are dumped from the
    user mode Ldt, rather than the system ldt.

Arguments:

    CurrentProcess -- Supplies a handle to the process to dump selectors for
    CurrentThread -- Supplies a handle to the thread to dump selectors for
    ArgumentString -- Supplies the arguments to the !sel command

Return Value

    None.

--*/
{

    PVOID pMem;
    BOOL bTrace;
    int Count;
    hCurrentProcess = CurrentProcess;

    if (!ReadMemExpression("ntvdm!bDpmiTraceOn", &bTrace, 4)) {
        return;
    }
    pMem = (PVOID)(*GetExpression)("ntvdm!bDpmiTraceOn");
    if (!pMem) {
        PRINTF("DPMI trace history not available\n");
        return;
    }

    if (!ReadDword(pMem, bTrace)) {
        PRINTF("Error reading memory\n");
        return;
    }

    if (!bTrace) {
        int Count = 0;
        bTrace = 1;
        WriteDword(pMem, bTrace);
        pMem = (PVOID)(*GetExpression)("ntvdm!bDpmiTraceCount");
        WriteDword(pMem, Count);
        (*Print)("Trace is now on and reset\n");
    } else {
        bTrace = 0;
        WriteDword(pMem, bTrace);
        (*Print)("Trace is now off\n");
    }
}
示例#9
0
void CRulesManager::ReadRule(LPCTSTR RuleName, USB_DK_HIDE_RULE &Rule) const
{
    Rule.Type  = ReadDword(RuleName, USBDK_HIDE_RULE_TYPE);
    Rule.Hide  = ReadBool(RuleName, USBDK_HIDE_RULE_SHOULD_HIDE);
    Rule.VID   = ReadDwordMask(RuleName, USBDK_HIDE_RULE_VID);
    Rule.PID   = ReadDwordMask(RuleName, USBDK_HIDE_RULE_PID);
    Rule.BCD   = ReadDwordMask(RuleName, USBDK_HIDE_RULE_BCD);
    Rule.Class = ReadDwordMask(RuleName, USBDK_HIDE_RULE_CLASS);
}
示例#10
0
	Stream* Stream::Deserialize(bool decompress)
	{
		Stream* value = new Stream();
		unsigned int length = ReadDword();
		StreamBuffer tmpBuffer(length, 0);
		ReadData(tmpBuffer);
		value->WriteData(tmpBuffer);
		value->Rewind();
		if (decompress)
			value->Inflate();
		return value;
	}
示例#11
0
void CMsregPacketRegistrationResponse::ReadDataFromFile(CFile& cfFile, DWORD& dwChecksum)
{
	// Read inherited data.
	CMsregPacket::ReadDataFromFile(cfFile, dwChecksum);

	// Read the product name.
	m_csProductName = ReadString(cfFile, dwChecksum);

	// Read the registered flag.
	m_dwRegistered = ReadDword(cfFile, dwChecksum);

	// Read the message (normally empty if successful).
	m_csMessage = ReadString(cfFile, dwChecksum);
}
示例#12
0
	std::string Stream::ReadString()
	{
		unsigned int length = ReadDword();
		if (streamMode == SmMemory)
		{
			std::string value(reinterpret_cast<const char*>(buffer.data() + position), length);
			position += length;
			return value;
		}
		else
		{
			std::string value(length, '\0');
			fileStream.read(const_cast<char*>(value.data()), length);
			return value;
		}
		return "";
	}
示例#13
0
void CMsregPacketHeader::ReadDataFromFile(CFile& cfFile, DWORD& dwChecksum)
{
	// Read inherited data.
	CMsregPacket::ReadDataFromFile(cfFile, dwChecksum);

	// Read customer ID.
	m_csCustomerId = ReadString(cfFile, dwChecksum);

	// Read packet count.
	DWORD dwPackets = ReadDword(cfFile, dwChecksum);

	// Read packets.
	DeleteAllPackets();
	for (DWORD i = 0; i < dwPackets; i++)
	{
		AddPacket(ReadPacket(cfFile));
	}
}
示例#14
0
BOOL CNodedMemoryBuffer::ReadNextFieldHeader()
{
   ASSERT(IsLoading());
   m_iNodeType = ID_END_OF_FIELDS;
   m_dwFieldSize = 0;

   m_iFieldType = ReadInt();

   switch(m_iFieldType)
   {
   case ID_END_OF_FIELDS:
      return FALSE;

   case ID_FIELD_IS_NODE:
      m_iNodeType = ReadInt();
      return TRUE;

   default:
      m_dwFieldSize = ReadDword();
      return TRUE;
   }
}
int main()
{
    HANDLE hProc = GetCurrentProcess();

    HANDLE hToken = NULL;
    if (!OpenProcessToken(hProc, TOKEN_ADJUST_PRIVILEGES, &hToken))
        printf("Failed to open access token\n");

    if (!SetPrivilege(hToken, SE_DEBUG_NAME, TRUE))
        printf("Failed to set debug privilege\n");

    DWORD pid = 5356;
    HANDLE hTargetProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
    if (!hTargetProc)
        printf("Failed to open process: %u\n", GetLastError());

    DWORD_PTR address = 0x001E0000;
    WriteDword(hTargetProc, address, 0xDEADBEEF);
    printf("Result of reading dword at 0x%llx address = 0x%x\n", address, ReadDword(hTargetProc, address));

    CloseHandle(hTargetProc);
    return 0;
}
示例#16
0
	bool Stream::ReadBoolean()
	{
		return ReadDword() >= 1;
	}
示例#17
0
HRESULT CHdmvClipInfo::ReadCpiInfo(CAtlArray<SyncPoint>* sps)
{
	sps->RemoveAll();

	CAtlArray<ClpiEpMapEntry> ClpiEpMapList;

	LARGE_INTEGER Pos = {0, 0};
	Pos.QuadPart = Cpi_start_addrress;
	SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);

	DWORD len = ReadDword();
	if (len == 0) {
		return E_FAIL;
	}

	BYTE* buf = NULL;

	ReadByte();
	BYTE Type = ReadByte() & 0xF;
	DWORD ep_map_pos = Cpi_start_addrress + 4 + 2;
	ReadByte();
	BYTE num_stream_pid = ReadByte();

	DWORD size = num_stream_pid * 12;
	buf = DNew BYTE[size];
	ReadBuffer(buf, size);
	CGolombBuffer gb(buf, size);
	for (int i = 0; i < num_stream_pid; i++) {
		ClpiEpMapEntry em;

		em.pid						= gb.ReadShort();
		gb.BitRead(10);
		em.ep_stream_type			= gb.BitRead(4);
		em.num_ep_coarse			= gb.ReadShort();
		em.num_ep_fine				= gb.BitRead(18);
		em.ep_map_stream_start_addr	= gb.ReadDword() + ep_map_pos;

		em.coarse					= DNew ClpiEpCoarse[em.num_ep_coarse];
		em.fine						= DNew ClpiEpFine[em.num_ep_fine];

		ClpiEpMapList.Add(em);
	}
	delete[] buf;

	for (int i = 0; i < num_stream_pid; i++) {
		ClpiEpMapEntry* em = &ClpiEpMapList[i];

		Pos.QuadPart = em->ep_map_stream_start_addr;
		SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);
		DWORD fine_start = ReadDword();

		size = em->num_ep_coarse * 8;
		buf = DNew BYTE[size];
		ReadBuffer(buf, size);
		gb.Reset(buf, size);

		for (int j = 0; j < em->num_ep_coarse; j++) {
			em->coarse[j].ref_ep_fine_id	= gb.BitRead(18);
			em->coarse[j].pts_ep			= gb.BitRead(14);
			em->coarse[j].spn_ep			= gb.ReadDword();
		}
		delete[] buf;

		Pos.QuadPart = em->ep_map_stream_start_addr+fine_start;
		SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);

		size = em->num_ep_fine * 4;
		buf = DNew BYTE[size];
		ReadBuffer(buf, size);
		gb.Reset(buf, size);

		for (int j = 0; j < em->num_ep_fine; j++) {
			em->fine[j].is_angle_change_point	= gb.BitRead(1);
			em->fine[j].i_end_position_offset	= gb.BitRead(3);
			em->fine[j].pts_ep					= gb.BitRead(11);
			em->fine[j].spn_ep					= gb.BitRead(17);
		}
		delete[] buf;
	}

	if (ClpiEpMapList.GetCount() > 0) {
		const ClpiEpMapEntry* entry = &ClpiEpMapList[0];
		for (int i = 0; i < entry->num_ep_coarse; i++) {
			int start, end;

			const ClpiEpCoarse* coarse = &entry->coarse[i];
			start = coarse->ref_ep_fine_id;
			if (i < entry->num_ep_coarse - 1) {
				end = entry->coarse[i+1].ref_ep_fine_id;
			} else {
				end = entry->num_ep_fine;
			}

			for (int j = start; j < end; j++) {
				ClpiEpFine* fine = &entry->fine[j];
				uint64 pts = ((uint64)(coarse->pts_ep & ~0x01) << 18) +
							 ((uint64)fine->pts_ep << 8);
				uint32 spn = (coarse->spn_ep & ~0x1FFFF) + fine->spn_ep;

				SyncPoint sp = {REFERENCE_TIME(20000.0f*pts/90), (__int64)spn * 192};
				sps->Add(sp);
			}
		}
	}

	for (size_t ii = 0; ii < ClpiEpMapList.GetCount(); ii++) {
		delete[] ClpiEpMapList[ii].coarse;
		delete[] ClpiEpMapList[ii].fine;
	}

	ClpiEpMapList.RemoveAll();

	return S_OK;
}
示例#18
0
HRESULT CHdmvClipInfo::ReadChapters(CString strPlaylistFile, CAtlList<CHdmvClipInfo::PlaylistItem>& PlaylistItems, CAtlList<PlaylistChapter>& Chapters)
{
    CPath Path(strPlaylistFile);

    // Get BDMV folder
    Path.RemoveFileSpec();
    Path.RemoveFileSpec();

    m_hFile = CreateFile(strPlaylistFile, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
                         OPEN_EXISTING, FILE_ATTRIBUTE_READONLY | FILE_FLAG_SEQUENTIAL_SCAN, NULL);

    if (m_hFile != INVALID_HANDLE_VALUE) {
        REFERENCE_TIME* rtOffset = DEBUG_NEW REFERENCE_TIME[PlaylistItems.GetCount()];
        REFERENCE_TIME rtSum = 0;
        int nIndex = 0;
        BYTE Buff[100];
        bool bDuplicate = false;

        POSITION pos = PlaylistItems.GetHeadPosition();
        while (pos) {
            CHdmvClipInfo::PlaylistItem& PI = PlaylistItems.GetNext(pos);

            rtOffset[nIndex] = rtSum - PI.m_rtIn;
            rtSum = rtSum + PI.Duration();
            nIndex++;
        }

        ReadBuffer(Buff, 4);
        if (memcmp(Buff, "MPLS", 4)) {
            SAFE_DELETE_ARRAY(rtOffset);
            return CloseFile(VFW_E_INVALID_FILE_FORMAT);
        }

        ReadBuffer(Buff, 4);
        if ((memcmp(Buff, "0200", 4) != 0) && (memcmp(Buff, "0100", 4) != 0)) {
            SAFE_DELETE_ARRAY(rtOffset);
            return CloseFile(VFW_E_INVALID_FILE_FORMAT);
        }

        LARGE_INTEGER  Pos;
        unsigned short nMarkCount;

        ReadDword();                // PlayList_start_address
        Pos.QuadPart = ReadDword(); // PlayListMark_start_address

        // PlayListMark()
        SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);
        ReadDword();                // length
        nMarkCount = ReadShort();   // number_of_PlayList_marks
        for (size_t i = 0; i < nMarkCount; i++) {
            PlaylistChapter Chapter;

            ReadByte();                                           // reserved_for_future_use
            Chapter.m_nMarkType   = (PlaylistMarkType)ReadByte(); // mark_type
            Chapter.m_nPlayItemId = ReadShort();                  // ref_to_PlayItem_id
            Chapter.m_rtTimestamp = 20000i64 * ReadDword() / 90 + rtOffset[Chapter.m_nPlayItemId];    // mark_time_stamp
            Chapter.m_nEntryPID   = ReadShort();                  // entry_ES_PID
            Chapter.m_rtDuration  = 20000i64 * ReadDword() / 90;  // duration

            Chapters.AddTail(Chapter);

            //TRACE(_T("Chapter %d : %s\n"), i, ReftimeToString(Chapter.m_rtTimestamp));
        }

        CloseFile(S_OK);
        SAFE_DELETE_ARRAY(rtOffset);
        return bDuplicate ? S_FALSE : S_OK;
    }

    return AmHresultFromWin32(GetLastError());
}
示例#19
0
ULONG64 CRulesManager::ReadBool(LPCTSTR RuleName, LPCTSTR ValueName) const
{
    return HideRuleBoolFromRegistry(ReadDword(RuleName, ValueName));
}
示例#20
0
bool CVobFile::Open(CString fn, CAtlList<CString>& vobs, ULONG nProgNum /*= 1*/, bool bAuthenticate /*= true*/)
{
    if (!m_ifoFile.Open(fn, CFile::modeRead | CFile::typeBinary | CFile::shareDenyNone)) {
        return false;
    }

    char hdr[IFO_HEADER_SIZE + 1];
    m_ifoFile.Read(hdr, IFO_HEADER_SIZE);
    hdr[IFO_HEADER_SIZE] = '\0';
    if (strcmp(hdr, VTS_HEADER)) {
        return false;
    }

    // Audio streams ...
    m_ifoFile.Seek(0x202, CFile::begin);
    BYTE buffer[SUBTITLE_BLOCK_SIZE];
    m_ifoFile.Read(buffer, AUDIO_BLOCK_SIZE);
    CGolombBuffer gb(buffer, AUDIO_BLOCK_SIZE);
    int stream_count = gb.ReadShort();
    for (int i = 0; i < std::min(stream_count, 8); i++) {
        BYTE Coding_mode = (BYTE)gb.BitRead(3);
        gb.BitRead(5);// skip
        int ToAdd = 0;
        switch (Coding_mode) {
            case 0:
                ToAdd = 0x80;
                break;
            case 4:
                ToAdd = 0xA0;
                break;
            case 6:
                ToAdd = 0x88;
                break;
            default:
                break;
        }
        gb.ReadByte();// skip
        char lang[2];
        gb.ReadBuffer((BYTE*)lang, 2);
        gb.ReadDword();// skip
        if (ToAdd) {
            m_pStream_Lang[ToAdd + i] = ISO6391ToLanguage(lang);
        }
    }

    // Subtitle streams ...
    m_ifoFile.Seek(0x254, CFile::begin);
    m_ifoFile.Read(buffer, SUBTITLE_BLOCK_SIZE);
    CGolombBuffer gb_s(buffer, SUBTITLE_BLOCK_SIZE);
    stream_count = gb_s.ReadShort();
    for (int i = 0; i < std::min(stream_count, 32); i++) {
        gb_s.ReadShort();
        char lang[2];
        gb_s.ReadBuffer((BYTE*)lang, 2);
        gb_s.ReadShort();
        m_pStream_Lang[0x20 + i] = ISO6391ToLanguage(lang);
    }

    // Chapters ...
    m_ifoFile.Seek(0xCC, CFile::begin); //Get VTS_PGCI address
    DWORD pcgITPosition = ReadDword() * 2048;
    m_ifoFile.Seek(pcgITPosition, CFile::begin);
    WORD nProgCount = (WORD)ReadShort();
    if (nProgNum > nProgCount) {
        return false;
    }
    m_ifoFile.Seek(pcgITPosition + 8 * nProgNum + 4, CFile::begin);
    DWORD chainOffset = ReadDword();
    m_ifoFile.Seek(pcgITPosition + chainOffset + 2, CFile::begin);
    BYTE programChainPrograms = ReadByte();
    m_iChaptersCount = programChainPrograms;
    m_ifoFile.Seek(pcgITPosition + chainOffset + 230, CFile::begin);
    int programMapOffset = ReadShort();
    m_ifoFile.Seek(pcgITPosition + chainOffset + 0xE8, CFile::begin);
    int cellTableOffset = ReadShort();
    REFERENCE_TIME rtDuration = 0;
    m_pChapters[0] = 0;
    for (BYTE currentProgram = 0; currentProgram < programChainPrograms; currentProgram++) {
        m_ifoFile.Seek(pcgITPosition + chainOffset + programMapOffset + currentProgram, CFile::begin);
        byte entryCell = ReadByte();
        byte exitCell = entryCell;
        if (currentProgram < (programChainPrograms - 1)) {
            m_ifoFile.Seek(pcgITPosition + chainOffset + programMapOffset + (currentProgram + 1), CFile::begin);
            exitCell = ReadByte() - 1;
        }

        REFERENCE_TIME rtTotalTime = 0;
        for (int currentCell = entryCell; currentCell <= exitCell; currentCell++) {
            int cellStart = cellTableOffset + ((currentCell - 1) * 0x18);
            m_ifoFile.Seek(pcgITPosition + chainOffset + cellStart, CFile::begin);
            BYTE bytes[4];
            ReadBuffer(bytes, 4);
            int cellType = bytes[0] >> 6;
            if (cellType == 0x00 || cellType == 0x01) {
                m_ifoFile.Seek(pcgITPosition + chainOffset + cellStart + 4, CFile::begin);
                ReadBuffer(bytes, 4);
                short frames = GetFrames(bytes[3]);
                int fpsMask = bytes[3] >> 6;
                double fps = fpsMask == 0x01 ? 25 : fpsMask == 0x03 ? (30 / 1.001) : 0;
                CString tmp;
                int hours = bytes[0];
                tmp.Format(_T("%x"), hours);
                _stscanf_s(tmp, _T("%d"), &hours);
                int minutes = bytes[1];
                tmp.Format(_T("%x"), minutes);
                _stscanf_s(tmp, _T("%d"), &minutes);
                int seconds = bytes[2];
                tmp.Format(_T("%x"), seconds);
                _stscanf_s(tmp, _T("%d"), &seconds);
                int mmseconds = 0;
                if (fps != 0) {
                    mmseconds = (int)(1000 * frames / fps);
                }

                REFERENCE_TIME rtCurrentTime = 10000i64 * (((hours * 60 + minutes) * 60 + seconds) * 1000 + mmseconds);
                rtTotalTime += rtCurrentTime;
            }
        }
        rtDuration += rtTotalTime;
        m_pChapters[currentProgram + 1] = rtDuration;
    }
示例#21
0
HRESULT CHdmvClipInfo::ReadChapters(CString strPlaylistFile, CPlaylist& PlaylistItems, CPlaylistChapter& Chapters)
{
	BYTE	Buff[4];
	CPath	Path(strPlaylistFile);

	// Get BDMV folder
	Path.RemoveFileSpec();
	Path.RemoveFileSpec();

	m_hFile = CreateFile(strPlaylistFile, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
							OPEN_EXISTING, FILE_ATTRIBUTE_READONLY|FILE_FLAG_SEQUENTIAL_SCAN, NULL);

	if (m_hFile != INVALID_HANDLE_VALUE) {
		REFERENCE_TIME*		rtOffset = DNew REFERENCE_TIME[PlaylistItems.GetCount()];
		REFERENCE_TIME		rtSum	 = 0;
		USHORT				nIndex   = 0;

		POSITION pos = PlaylistItems.GetHeadPosition();
		while (pos) {
			CHdmvClipInfo::PlaylistItem* PI = PlaylistItems.GetNext(pos);

			rtOffset[nIndex]	= rtSum - PI->m_rtIn;
			rtSum				= rtSum + PI->Duration();
			nIndex++;
		}

		ReadBuffer(Buff, 4);
		if (memcmp(Buff, "MPLS", 4)) {
			SAFE_DELETE_ARRAY(rtOffset);
			return CloseFile(VFW_E_INVALID_FILE_FORMAT);
		}

		ReadBuffer(Buff, 4);
		if ((memcmp(Buff, "0200", 4)!=0) && (memcmp(Buff, "0100", 4)!=0)) {
			SAFE_DELETE_ARRAY(rtOffset);
			return CloseFile(VFW_E_INVALID_FILE_FORMAT);
		}

		LARGE_INTEGER	Pos = {0, 0};
		USHORT			nMarkCount;

		ReadDword();				// PlayList_start_address
		Pos.QuadPart = ReadDword();	// PlayListMark_start_address

		// PlayListMark()
		SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);
		ReadDword();				// length
		nMarkCount = ReadShort();	// number_of_PlayList_marks
		for (size_t i = 0; i < nMarkCount; i++) {
			PlaylistChapter	Chapter;

			ReadByte();															// reserved_for_future_use
			Chapter.m_nMarkType		= (PlaylistMarkType)ReadByte();				// mark_type
			Chapter.m_nPlayItemId	= ReadShort();								// ref_to_PlayItem_id
			Chapter.m_rtTimestamp	= REFERENCE_TIME(20000.0f*ReadDword()/90) + rtOffset[Chapter.m_nPlayItemId];		// mark_time_stamp
			Chapter.m_nEntryPID		= ReadShort();								// entry_ES_PID
			Chapter.m_rtDuration	= REFERENCE_TIME(20000.0f*ReadDword()/90);	// duration

			if (Chapter.m_rtTimestamp < 0 || Chapter.m_rtTimestamp > rtSum) {
				continue;
			}

			Chapters.AddTail (Chapter);
		}

		CloseFile(S_OK);
		SAFE_DELETE_ARRAY(rtOffset);

		return S_OK;
	}

	return AmHresultFromWin32(GetLastError());
}
示例#22
0
HRESULT CHdmvClipInfo::ReadPlaylist(CString strPlaylistFile, REFERENCE_TIME& rtDuration, CPlaylist& Playlist, BOOL bFullInfoRead)
{

	BYTE	Buff[5];
	CPath	Path (strPlaylistFile);
	bool	bDuplicate = false;
	rtDuration  = 0;

	// Get BDMV folder
	Path.RemoveFileSpec();
	Path.RemoveFileSpec();

	m_hFile = CreateFile(strPlaylistFile, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
							OPEN_EXISTING, FILE_ATTRIBUTE_READONLY|FILE_FLAG_SEQUENTIAL_SCAN, NULL);

	if (m_hFile != INVALID_HANDLE_VALUE) {
		DbgLog((LOG_TRACE, 3, _T("CHdmvClipInfo::ReadPlaylist() : %s"), strPlaylistFile));

		ReadBuffer(Buff, 4);
		if (memcmp(Buff, "MPLS", 4)) {
			return CloseFile(VFW_E_INVALID_FILE_FORMAT);
		}

		ReadBuffer(Buff, 4);
		if ((memcmp(Buff, "0200", 4)) && (memcmp(Buff, "0100", 4))) {
			return CloseFile(VFW_E_INVALID_FILE_FORMAT);
		}

		LARGE_INTEGER	Pos = {0, 0};
		DWORD			dwTemp;
		USHORT			nPlaylistItems;

		Pos.QuadPart = ReadDword();	// PlayList_start_address
		ReadDword();				// PlayListMark_start_address

		// PlayList()
		SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);
		ReadDword();						// length
		ReadShort();						// reserved_for_future_use
		nPlaylistItems = ReadShort();		// number_of_PlayItems
		ReadShort();						// number_of_SubPaths

		Pos.QuadPart += 10;
		__int64 TotalSize = 0;
		for (size_t i = 0; i < nPlaylistItems; i++) {
			CAutoPtr<PlaylistItem> Item(DNew PlaylistItem);
			SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);
			Pos.QuadPart += ReadShort() + 2;
			ReadBuffer(Buff, 5);
			Item->m_strFileName.Format(_T("%s\\STREAM\\%c%c%c%c%c.M2TS"), CString(Path), Buff[0], Buff[1], Buff[2], Buff[3], Buff[4]);

			ReadBuffer(Buff, 4);
			if (memcmp(Buff, "M2TS", 4)) {
				return CloseFile(VFW_E_INVALID_FILE_FORMAT);
			}

			if (!::PathFileExists(Item->m_strFileName)) {
				DbgLog((LOG_TRACE, 3, _T("		==> %s is missing, skip it"), Item->m_strFileName));
				continue;
			}
			ReadBuffer(Buff, 3);

			dwTemp				= ReadDword();
			Item->m_rtIn		= REFERENCE_TIME(20000.0f*dwTemp/90);

			dwTemp				= ReadDword();
			Item->m_rtOut		= REFERENCE_TIME(20000.0f*dwTemp/90);

			Item->m_rtStartTime	= rtDuration;

			rtDuration += (Item->m_rtOut - Item->m_rtIn);

			if (bFullInfoRead) {
				LARGE_INTEGER size = {0, 0};
				HANDLE hFile = CreateFile(Item->m_strFileName, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
											OPEN_EXISTING, FILE_ATTRIBUTE_READONLY|FILE_FLAG_SEQUENTIAL_SCAN, NULL);
				if (hFile != INVALID_HANDLE_VALUE) {
					GetFileSizeEx(hFile, &size);
					CloseHandle(hFile);
				}

				Item->m_SizeIn	= TotalSize;
				TotalSize		+= size.QuadPart;
				Item->m_SizeOut	= TotalSize;
			}

			POSITION pos = Playlist.GetHeadPosition();
			while (pos) {
				PlaylistItem* pItem = Playlist.GetNext(pos);
				if (*pItem == *Item) {
					bDuplicate = true;
					break;
				}

			}

			DbgLog((LOG_TRACE, 3, _T("	==> %s, Duration : %s [%15I64d], Total duration : %s, Size : %I64d"), Item->m_strFileName, ReftimeToString(Item->Duration()), Item->Duration(), ReftimeToString(rtDuration), Item->Size()));

			Playlist.AddTail(Item);
		}

		CloseFile(S_OK);

		if (bFullInfoRead) {
			POSITION pos = Playlist.GetHeadPosition();
			while (pos) {
				PlaylistItem* pItem = Playlist.GetNext(pos);
				CString fname = pItem->m_strFileName;
				fname.Replace(L"\\STREAM\\", L"\\CLIPINF\\");
				fname.Replace(L".M2TS", L".CLPI");

				ReadInfo(fname, &pItem->m_sps);
			}
		}

		return Playlist.IsEmpty() ? E_FAIL : bDuplicate ? S_FALSE : S_OK;
	}

	return AmHresultFromWin32(GetLastError());
}
示例#23
0
	Stream* Stream::ReadBitmapOld()
	{
		if (ReadDword() == -1)
			return NULL;
		return Deserialize(false);
	}
示例#24
0
ULONG64 CRulesManager::ReadDwordMask(LPCTSTR RuleName, LPCTSTR ValueName) const
{
    return HideRuleUlongMaskFromRegistry(ReadDword(RuleName, ValueName));
}
示例#25
0
// function to read in a header
bool DDSImage::ReadHeader(const char* pDataIn, DDS::DDSStruct& header)
{
	const int headerSize=128;
	byte data[headerSize];
	byte * pData=data;
	memcpy(pData, pDataIn, sizeof(byte) * headerSize);

	// verify DDS files
	if (! (pData[0]=='D' && pData[1]=='D' && pData[2]=='S' && pData[3]==' ') )
	{
		return false;
	}
	pData+=4;

	header.size=ReadDword(pData);
	if (header.size!=124)
	{
		return false;
	}

	//convert the data
	header.flags=ReadDword(pData);
	header.height=ReadDword(pData);
	header.width=ReadDword(pData);
	header.sizeorpitch=ReadDword(pData);
	header.depth=ReadDword(pData);
	header.mipmapcount=ReadDword(pData);

	for (int i=0; i<11; ++i)
	{
		header.reserved[i]=ReadDword(pData);
	}
			
	//pixelfromat
	header.pixelformat.size=ReadDword(pData);
	header.pixelformat.flags=ReadDword(pData);
	header.pixelformat.fourCC=ReadDword(pData);
	header.pixelformat.RGBBitCount=ReadDword(pData);
	header.pixelformat.rBitMask=ReadDword(pData);
	header.pixelformat.gBitMask=ReadDword(pData);
	header.pixelformat.bBitMask=ReadDword(pData);
	header.pixelformat.alpahbitmask=ReadDword(pData);

	//caps
	header.ddscaps.caps1=ReadDword(pData);
	header.ddscaps.caps2=ReadDword(pData);
	header.ddscaps.reserved[0]=ReadDword(pData);
	header.ddscaps.reserved[1]=ReadDword(pData);
	header.reserved2=ReadDword(pData);

	headerdone_ = true;
	return headerdone_;
}
示例#26
0
DWORD CMsregPacket::ReadStringLength(CFile& cfFile, DWORD& dwChecksum)
{
	return ReadDword(cfFile, dwChecksum);
}
示例#27
0
HRESULT CHdmvClipInfo::ReadPlaylist(CString strPlaylistFile, REFERENCE_TIME& rtDuration, CAtlList<PlaylistItem>& Playlist)
{
    CPath Path(strPlaylistFile);
    rtDuration = 0;

    // Get BDMV folder
    Path.RemoveFileSpec();
    Path.RemoveFileSpec();

    m_hFile = CreateFile(strPlaylistFile, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
                         OPEN_EXISTING, FILE_ATTRIBUTE_READONLY | FILE_FLAG_SEQUENTIAL_SCAN, NULL);

    if (m_hFile != INVALID_HANDLE_VALUE) {
        BYTE Buff[100];
        bool bDuplicate = false;
        ReadBuffer(Buff, 4);
        if (memcmp(Buff, "MPLS", 4)) {
            return CloseFile(VFW_E_INVALID_FILE_FORMAT);
        }

        ReadBuffer(Buff, 4);
        if ((memcmp(Buff, "0200", 4) != 0) && (memcmp(Buff, "0100", 4) != 0)) {
            return CloseFile(VFW_E_INVALID_FILE_FORMAT);
        }

        LARGE_INTEGER Pos;
        DWORD  dwTemp;
        unsigned short nPlaylistItems;

        Pos.QuadPart = ReadDword(); // PlayList_start_address
        ReadDword();                // PlayListMark_start_address

        // PlayList()
        SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);
        ReadDword();                   // length
        ReadShort();                   // reserved_for_future_use
        nPlaylistItems = ReadShort();  // number_of_PlayItems
        ReadShort();                   // number_of_SubPaths

        Pos.QuadPart += 10;
        for (size_t i = 0; i < nPlaylistItems; i++) {
            PlaylistItem Item;
            SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);
            Pos.QuadPart += ReadShort() + 2;
            ReadBuffer(Buff, 5);
            Item.m_strFileName.Format(_T("%s\\STREAM\\%c%c%c%c%c.M2TS"), Path, Buff[0], Buff[1], Buff[2], Buff[3], Buff[4]);

            ReadBuffer(Buff, 4);
            if (memcmp(Buff, "M2TS", 4)) {
                return CloseFile(VFW_E_INVALID_FILE_FORMAT);
            }
            ReadBuffer(Buff, 3);

            dwTemp = ReadDword();
            Item.m_rtIn = 20000i64 * dwTemp / 90; // Carefull : 32->33 bits!

            dwTemp = ReadDword();
            Item.m_rtOut = 20000i64 * dwTemp / 90; // Carefull : 32->33 bits!

            rtDuration += (Item.m_rtOut - Item.m_rtIn);

            if (Playlist.Find(Item) != NULL) {
                bDuplicate = true;
            }
            Playlist.AddTail(Item);

            //TRACE(_T("File : %s, Duration : %s, Total duration  : %s\n"), strTemp, ReftimeToString (rtOut - rtIn), ReftimeToString (rtDuration));
        }

        CloseFile(S_OK);
        return bDuplicate ? S_FALSE : S_OK;
    }

    return AmHresultFromWin32(GetLastError());
}
示例#28
0
void CTapeBlock::ParseHeader(byte *header)
{
	pulse_pilot = Convert(2168);
	pulse_sync1 = Convert(667);
	pulse_sync2 = Convert(735);
	pulse_zero = Convert(855);
	pulse_one = Convert(1710);
	block_lastbit = 0;

	tape_pilot = 0;
	tape_sync = 0;
	tape_pause = 0;
	data_size = 0;

	if (!tapeTzx) {
		tape_pilot = 6000;
		tape_sync = 2;
		tape_pause = 2000;

		data_size = ReadWord(header);
		data_type = BLOCK_DATA;
	}
	else {
		switch (header[0]) {
			case 0x10:
				tape_pilot = 6000;
				tape_sync = 2;
				tape_pause = ReadWord(header + 1);

				data_size = ReadWord(header + 3);
				data_type = BLOCK_DATA;
				break;

			case 0x11:
				pulse_pilot = Convert(ReadWord(header + 1));
				pulse_sync1 = Convert(ReadWord(header + 3));
				pulse_sync2 = Convert(ReadWord(header + 5));
				pulse_zero = Convert(ReadWord(header + 7));
				pulse_one = Convert(ReadWord(header + 9));

				tape_pilot = ReadWord(header + 11);
				tape_sync = 2;
				block_lastbit = (8 - header[13]) * 2;
				tape_pause = ReadWord(header + 14);

				data_size = ReadWord3(header + 16);
				data_type = BLOCK_DATA;
				break;

			case 0x12:
				pulse_pilot = Convert(ReadWord(header + 1));
				tape_pilot = ReadWord(header + 3);
				break;

			case 0x13:
				data_size = header[1] * 2;
				data_type = SEQUENCE_DATA;
				break;

			case 0x14:
				pulse_zero = Convert(ReadWord(header + 1));
				pulse_one = Convert(ReadWord(header + 3));
				block_lastbit = (8 - header[5]) * 2;
				tape_pause = ReadWord(header + 6);

				data_size = ReadWord3(header + 8);
				data_type = BLOCK_DATA;
				break;

			case 0x15:
				data_size = ReadWord3(header + 6) * 2;
				data_type = SKIP_DATA;
				break;

			case 0x20:
				tape_pause = ReadWord(header + 1);
				break;

			case 0x21:
			case 0x30:
				data_size = header[1];
				data_type = SKIP_DATA;
				break;

			case 0x22:
			case 0x23:
			case 0x24:
			case 0x25:
				break;
			case 0x31:
				data_size = header[2];
				data_type = SKIP_DATA;
				break;
			case 0x32:
				data_size = ReadWord(header + 1);
				data_type = SKIP_DATA;
				break;
			case 0x33:
				data_size = header[1] * 3;
				data_type = SKIP_DATA;
				break;
			case 0x34:
				break;
			case 0x35:
				data_size = ReadDword(header + 0x11);
				data_type = SKIP_DATA;
				break;
			case 0x40:
				data_size = ReadWord3(header + 9);
				data_type = SKIP_DATA;
				break;

			case 0x5A:
				break;

			default:
				data_size = ReadDword(header + 1);
				data_type = SKIP_DATA;
				break;
		}
	}
}
示例#29
0
HRESULT CHdmvClipInfo::ReadProgramInfo()
{
    BYTE number_of_program_sequences;
    BYTE number_of_streams_in_ps;
    LARGE_INTEGER Pos;

    m_Streams.RemoveAll();
    Pos.QuadPart = ProgramInfo_start_address;
    SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);

    ReadDword();    //length
    ReadByte();     //reserved_for_word_align
    number_of_program_sequences = (BYTE)ReadByte();
    int iStream = 0;
    for (size_t i = 0; i < number_of_program_sequences; i++) {
        ReadDword();    //SPN_program_sequence_start
        ReadShort();    //program_map_PID
        number_of_streams_in_ps = (BYTE)ReadByte(); //number_of_streams_in_ps
        ReadByte();     //reserved_for_future_use

        for (size_t stream_index = 0; stream_index < number_of_streams_in_ps; stream_index++) {
            m_Streams.SetCount(iStream + 1);
            m_Streams[iStream].m_PID = ReadShort();  // stream_PID

            // == StreamCodingInfo
            Pos.QuadPart = 0;
            SetFilePointerEx(m_hFile, Pos, &Pos, FILE_CURRENT);
            Pos.QuadPart += ReadByte() + 1; // length
            m_Streams[iStream].m_Type = (PES_STREAM_TYPE)ReadByte();

            switch (m_Streams[iStream].m_Type) {
                case VIDEO_STREAM_MPEG1:
                case VIDEO_STREAM_MPEG2:
                case VIDEO_STREAM_H264:
                case VIDEO_STREAM_VC1: {
                    UINT8 Temp = ReadByte();
                    BDVM_VideoFormat VideoFormat = (BDVM_VideoFormat)(Temp >> 4);
                    BDVM_FrameRate FrameRate = (BDVM_FrameRate)(Temp & 0xf);
                    Temp = ReadByte();
                    BDVM_AspectRatio AspectRatio = (BDVM_AspectRatio)(Temp >> 4);

                    m_Streams[iStream].m_VideoFormat = VideoFormat;
                    m_Streams[iStream].m_FrameRate = FrameRate;
                    m_Streams[iStream].m_AspectRatio = AspectRatio;
                }
                break;
                case AUDIO_STREAM_MPEG1:
                case AUDIO_STREAM_MPEG2:
                case AUDIO_STREAM_LPCM:
                case AUDIO_STREAM_AC3:
                case AUDIO_STREAM_DTS:
                case AUDIO_STREAM_AC3_TRUE_HD:
                case AUDIO_STREAM_AC3_PLUS:
                case AUDIO_STREAM_DTS_HD:
                case AUDIO_STREAM_DTS_HD_MASTER_AUDIO:
                case SECONDARY_AUDIO_AC3_PLUS:
                case SECONDARY_AUDIO_DTS_HD: {
                    UINT8 Temp = ReadByte();
                    BDVM_ChannelLayout ChannelLayout = (BDVM_ChannelLayout)(Temp >> 4);
                    BDVM_SampleRate SampleRate = (BDVM_SampleRate)(Temp & 0xF);

                    ReadBuffer((BYTE*)m_Streams[iStream].m_LanguageCode, 3);
                    m_Streams[iStream].m_LanguageCode[3] = '\0';
                    m_Streams[iStream].m_LCID = ISO6392ToLcid(m_Streams[iStream].m_LanguageCode);
                    m_Streams[iStream].m_ChannelLayout = ChannelLayout;
                    m_Streams[iStream].m_SampleRate = SampleRate;
                }
                break;
                case PRESENTATION_GRAPHICS_STREAM:
                case INTERACTIVE_GRAPHICS_STREAM: {
                    ReadBuffer((BYTE*)m_Streams[iStream].m_LanguageCode, 3);
                    m_Streams[iStream].m_LanguageCode[3] = '\0';
                    m_Streams[iStream].m_LCID = ISO6392ToLcid(m_Streams[iStream].m_LanguageCode);
                }
                break;
                case SUBTITLE_STREAM: {
                    ReadByte(); // Should this really be here?
                    ReadBuffer((BYTE*)m_Streams[iStream].m_LanguageCode, 3);
                    m_Streams[iStream].m_LanguageCode[3] = '\0';
                    m_Streams[iStream].m_LCID = ISO6392ToLcid(m_Streams[iStream].m_LanguageCode);
                }
                break;
                default:
                    break;
            }

            iStream++;
            SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);
        }
    }
    return S_OK;
}
DWORD RegistryHandler::ReadDwordEx (LPCSTR szKey)
{
	return ReadDword ("Software\\CedeSoft\\CommunicatorClient", szKey);
}