参考这个帖子设置winpe。
http://lrxianed.diandian.com/post/2011-04-09/4710715
解压出winnt.xpe放置到根目录,
解压出NTDETECT.COM文件以及SETUPLDR.BIN放置到根目录,重命名SETUPLDR.BIN->NTLDR
下载ltntldr
ldntldr.bin.tgz
然后复制ldntldr.bin复制到根目录,修改为ltntldr
提取athlon.im_到winpe目录。
修改winnt.xpe指定wim文件的位置:
[SetupData] BootDevice = "ramdisk(0)" BootPath = "\WXPE\System32\" OsLoadOptions = "/minint /fastdetect /rdpath=\WINPE\ATHLON.IM_"
G:\>dir /a:H 驱动器 G 中的卷是 LIVETOOLS 卷的序列号是 F89A-2FF9 G:\ 的目录 2013/06/25 18:40 617 syslinux.cfg 2013/01/08 10:32 <DIR> backup 2013/01/08 13:22 32,256 ldlinux.sys 2013/06/21 07:15 <DIR> autorun.inf 2013/06/21 11:48 135 WINNT.XPE 2006/11/11 10:00 47,564 NTDETECT.COM 2003/01/01 04:02 297,584 NTLDR 2008/03/01 16:54 1,024 LDNTLDR 2004/08/17 20:00 322,730 BOOTFONT.BIN 2013/06/21 11:48 <DIR> winpe 2013/06/21 13:10 <DIR> puppy 2011/04/19 05:24 56,164 menu.c32 2011/04/19 05:24 155,792 vesamenu.c32 2011/04/19 05:24 800 reboot.c32 2013/06/25 11:11 <DIR> core 2013/06/25 11:34 <DIR> cde 10 个文件 914,666 字节 6 个目录 10,010,624 可用字节
插入一段驱动精灵里面的net.dll文件的解析代码:
#include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <string.h> #include <stdlib.h> #include <list> #include <string> typedef int uint32; typedef struct { char drvname [0x100]; // 原文件中每个驱动包的名字好像都不超过0x24 uint32 drvlen; }drv_item; /** * 驱动文件集合的头部结构大概如此 * * + count * { * + zip file name length * + zip file file name( char array ) * + zip file length * } * ... // 一共count个 * 第一个zip的文件内容 * 第二个zip的文件内容 * ... * 第count个zip的文件内容 * */ typedef struct { uint32 count; drv_item items[1]; // ... // zips' content }net_drv_head; int main(int argc, char * argv[]) { int fsize = 0; struct stat st; char * bufptr = 0; uint32 drvindex = 0; FILE * drvf = fopen(argv[1], "rb"); if (!drvf) return -1; if (stat(argv[1], &st)) return -1; printf("file size : %d\n", st.st_size); char * drvbuffer = (char *)malloc(st.st_size); if (!drvbuffer) return -1; if (st.st_size != fread(drvbuffer, 1, st.st_size, drvf)) return -1; mkdir("zips", 0777); bufptr = drvbuffer; uint32 drvcount = *(uint32 *)bufptr; bufptr += sizeof(uint32); printf("driver count : %d\n", drvcount); net_drv_head * pHead = (net_drv_head*) malloc (sizeof(net_drv_head) + sizeof(drv_item) * (drvcount-1)); pHead->count = drvcount; drv_item * pItem = &pHead->items[0]; for (drvindex = 0; drvindex < drvcount; drvindex++){ char drvname [0x100] = ""; uint32 drvfilelen = 0; uint32 drvnamelen = *(uint32 *)bufptr; bufptr += sizeof(uint32); memcpy(drvname, bufptr, drvnamelen); bufptr += drvnamelen; drvname[drvnamelen] = '\0'; drvfilelen = *(uint32 *)bufptr; bufptr += sizeof(uint32); printf("strlen: %d, str: %s, filelen: %d\n" , drvnamelen , drvname , drvfilelen); strcpy(pItem->drvname, "zips/"); strcat(pItem->drvname, drvname); pItem->drvlen = drvfilelen; pItem ++; } for (int i = 0; i < pHead->count; i++){ printf("%s, %d\n", pHead->items[i].drvname, pHead->items[i].drvlen); FILE * zip = fopen(pHead->items[i].drvname, "wb"); fwrite(bufptr, 1, pHead->items[i].drvlen, zip); bufptr += pHead->items[i].drvlen; fclose(zip); } free(drvbuffer); fclose(drvf); return 0; }
解析出来的zip都放置在zips文件夹下,tar出来看看。
DEFAULT vesamenu.c32 TIMEOUT 300 MENU TITLE MENU COLOR BORDER 30;44 #00000000 #00000000 none LABEL winpe MENU LABEL [01] start Windows PE. KERNEL /ldntldr APPEND initrd=/ntldr LABEL puppy MENU LABEL [02] start Wary Puppy Linux. KERNEL /puppy/vmlinuz PMEDIA=usbflash APPEND initrd=/puppy/initrd.gz LABEL core MENU LABEL [03] start Tiny Core Linux. KERNEL /core/vmlinuz APPEND initrd=/core/core.gz LABEL guicore MENU LABEL [04] start Tiny Core Linux with GUI. KERNEL /core/vmlinuz APPEND initrd=/core/core.gz cde LABEL reboot MENU LABEL [05] Reboot. KERNEL /reboot.c32