打印

开帖研究WINCE之EBOOT

[复制链接]
1332|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
sxggj|  楼主 | 2008-9-19 10:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
void BootloaderMain (void)
{
    ROMHDR *pRomHdr = NULL;  // pTOC for NK image. MUST COPY IT OR CLEANBOOT may erase it
    DWORD dwAction, dwpToc;   
    DWORD dwImageStart = 0, dwImageLength = 0, dwLaunchAddr = 0;
    BOOL bDownloaded = FALSE;

    // relocate globals to RAM
    if (!KernelRelocate (pTOC)) {
        // spin forever
        HALT (BLERR_KERNELRELOCATE);
    }
**********************************
static BOOL KernelRelocate (ROMHDR *const pTOC)
{
    ULONG loop;
    COPYentry *cptr;
    if (pTOC == (ROMHDR *const) -1) {
        return FALSE; // spin forever!
    }
    // This is where the data sections become valid... don't read globals until after this
    for (loop = 0; loop < pTOC->ulCopyEntries; loop++) {
        cptr = (COPYentry *)(pTOC->ulCopyOffset + loop*sizeof(COPYentry));
        if (cptr->ulCopyLen)
            memcpy((LPVOID)cptr->ulDest,(LPVOID)cptr->ulSource,cptr->ulCopyLen);
        if (cptr->ulCopyLen != cptr->ulDestLen)
            memset((LPVOID)(cptr->ulDest+cptr->ulCopyLen),0,cptr->ulDestLen-cptr->ulCopyLen);
    }
    return TRUE;
}
**********************************
第一个问题:ROMHDR结构体内容分析:
typedef struct ROMHDR {
    ULONG   dllfirst;               // first DLL address
    ULONG   dlllast;                // last DLL address
    ULONG   physfirst;              // first physical address
    ULONG   physlast;               // highest physical address
    ULONG   nummods;                // number of TOCentry's
    ULONG   ulRAMStart;             // start of RAM
    ULONG   ulRAMFree;              // start of RAM free space
    ULONG   ulRAMEnd;               // end of RAM
    ULONG   ulCopyEntries;          // number of copy section entries
    ULONG   ulCopyOffset;           // offset to copy section
    ULONG   ulProfileLen;           // length of PROFentries RAM 
    ULONG   ulProfileOffset;        // offset to PROFentries
    ULONG   numfiles;               // number of FILES
    ULONG   ulKernelFlags;          // optional kernel flags from ROMFLAGS .bib config option
    ULONG   ulFSRamPercent;         // Percentage of RAM used for filesystem 
                                        // from FSRAMPERCENT .bib config option
                                        // byte 0 = #4K chunks/Mbyte of RAM for filesystem 0-2Mbytes 0-255
                                        // byte 1 = #4K chunks/Mbyte of RAM for filesystem 2-4Mbytes 0-255
                                        // byte 2 = #4K chunks/Mbyte of RAM for filesystem 4-6Mbytes 0-255
                                        // byte 3 = #4K chunks/Mbyte of RAM for filesystem > 6Mbytes 0-255

    ULONG   ulDrivglobStart;        // device driver global starting address
    ULONG   ulDrivglobLen;          // device driver global length
    USHORT  usCPUType;              // CPU (machine) Type
    USHORT  usMiscFlags;            // Miscellaneous flags
    PVOID   pExtensions;            // pointer to ROM Header extensions
    ULONG   ulTrackingStart;        // tracking memory starting address
    ULONG   ulTrackingLen;          // tracking memory ending address
} ROMHDR;

相关帖子

沙发
sxggj|  楼主 | 2008-9-19 10:58 | 只看该作者

关于COPYentry

//  Copy Section Structure
//
#ifdef ASM_ONLY
#define COPYentry_ulSource      0
#define COPYentry_ulDest        4
#define COPYentry_ulCopyLen     8
#define COPYentry_ulDestLen     12
#define SIZEOF_COPYentry        16
#else
typedef struct COPYentry {
    ULONG   ulSource;               // copy source address
    ULONG   ulDest;                 // copy destination address
    ULONG   ulCopyLen;              // copy length
    ULONG   ulDestLen;              // copy destination length 
                                    // (zero fill to end if > ulCopyLen)
} COPYentry;
#endif

使用特权

评论回复
板凳
sxggj|  楼主 | 2008-9-19 12:28 | 只看该作者

memcpy与memset

void *memcpy( void *dest, const void *src, size_t count );
void *memset( void *dest, int c, size_t count );
这两个函数只有参数说明,没有源码,因为这部分属于操作系统内核部分,而且微软并未公布源码,只能看汇编

使用特权

评论回复
地板
| | 2008-9-19 16:49 | 只看该作者

ding...

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

230

主题

1397

帖子

3

粉丝