rogs3210
驱动牛犊
驱动牛犊
  • 注册日期2009-05-13
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分10分
  • 威望71点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:2039回复:0

binfs分区

楼主#
更多 发布于:2010-01-21 11:25
HANDLE BP_OpenPartition(DWORD dwStartSector, DWORD dwNumSectors, DWORD dwPartType, BOOL fActive, DWORD dwCreationFlags)
{
        DWORD dwPartIndex;
        BOOL fExists;

        ASSERT (g_pbMBRSector);
        
        if (!IsValidMBR())
        {
            DWORD dwFlags = 0;

            if (dwCreationFlags == PART_OPEN_EXISTING)
            {
                RETAILMSG(1, (TEXT("OpenPartition: Invalid MBR.  Cannot open existing partition 0x%x.\r\n"), dwPartType));
                return INVALID_HANDLE_VALUE;
            }
            
            RETAILMSG(1, (TEXT("OpenPartition: Invalid MBR.  Formatting flash.\r\n")));
            if (g_FlashInfo.flashType == NOR)
            {
                dwFlags |= FORMAT_SKIP_BLOCK_CHECK;
            }
            BP_LowLevelFormat (0,g_FlashInfo.dwNumBlocks, dwFlags);
            dwPartIndex = 0;
            fExists = FALSE;
        }
        else
        {
            fExists = GetPartitionTableIndex(dwPartType, fActive, &dwPartIndex);        
        }

        RETAILMSG(1, (TEXT("OpenPartition: Partition Exists=0x%x for part 0x%x.\r\n"), fExists, dwPartType));

        if (fExists)
        {

            // Partition was found.  
            if (dwCreationFlags == PART_CREATE_NEW)
                return INVALID_HANDLE_VALUE;
            
            if (g_partStateTable[dwPartIndex].pPartEntry == NULL)
            {
                // Open partition.  If this is the boot section partition, then file pointer starts after MBR
                g_partStateTable[dwPartIndex].pPartEntry = (PPARTENTRY)(g_pbMBRSector + PARTTABLE_OFFSET + sizeof(PARTENTRY)*dwPartIndex);
                g_partStateTable[dwPartIndex].dwDataPointer = 0;
            }            
            return (HANDLE)&g_partStateTable[dwPartIndex];            
        }
        else
        {

            // If there are already 4 partitions, or creation flag specified OPEN_EXISTING, fail.
            if ((dwPartIndex == NUM_PARTS) || (dwCreationFlags == PART_OPEN_EXISTING))
                return INVALID_HANDLE_VALUE;

            // Create new partition
            return CreatePartition (dwStartSector, dwNumSectors, dwPartType, fActive, dwPartIndex);
        }

        return INVALID_HANDLE_VALUE;
        
}
请教各位高手 binfs分区:
BP_LowLevelFormat (0,g_FlashInfo.dwNumBlocks, dwFlags);
这个函数的参数要改吗
游客

返回顶部