无忧启动论坛

标题: PE中如何加载dummy.sys驱动? [打印本页]

作者: qdaijchf    时间: 2010-5-27 19:43
标题: PE中如何加载dummy.sys驱动?
搜索了victor888版主的帖子,http://bbs.wuyou.net/forum.php?mod=viewthread&tid=129531&highlight=rdummy介绍了加载rdummy.sys驱动,把U盘从fixed disk变成removable disk的方法,但我正好相反,想在PE中加载dummy.sys驱动,把U盘从removable disk变成fixed disk

[ 本帖最后由 qdaijchf 于 2010-5-27 19:56 编辑 ]

dummy.rar

1.66 KB, 下载次数: 69, 下载积分: 无忧币 -2


作者: ones    时间: 2010-5-27 19:59
可以参照论坛里添加HFS驱动的方式修改txtsetup.sif文件或者参照0PE里添加支持麦金塔HFSplus格式磁盘.WIM
作者: qdaijchf    时间: 2010-5-27 20:14
谢谢,我查一查,试试看。
作者: dvd008    时间: 2010-5-27 20:43
http://bbs.wuyou.net/forum.php?mod=viewthread&tid=163914

里面有个启动SYS为服务的工具,然后重启SHELL
作者: qdaijchf    时间: 2010-5-27 21:16
谢谢D大,已经搞定。但重启SHELL以后,U盘没有马上变成fixed disk,而是经过插拔以后才被加载为fixed disk。这样PE启动到桌面后还是不能自动加载U盘第二分区的PETOOLS,必须得手工操作。要是在txtsetup.sif中加载就好了。
作者: dvd008    时间: 2010-5-27 21:45
sys放到DRV目录

按照EXFAT.SYS 格式,TXT里面加入3行(第一行可以没有)

会不会有其它问题就不知道了
作者: qdaijchf    时间: 2010-5-28 08:23
在txtsetup.sif中加了两行,基本上搞定,比进入桌面后加载dummy.sys前进了一步,因为不用重启shell,但还是要插拔一次U盘。
有没有办法不用插拔U盘,完成一次相当于插拔的动作,即弹出然后加载U盘。
作者: 123    时间: 2010-5-28 09:09
原帖由 <i>qdaijchf</i> 于 2010-5-28 08:23 发表 <a href="http://bbs.wuyou.net/redirect.php?goto=findpost&pid=1959777&ptid=164013" target="_blank"><img src="http://bbs.wuyou.net/images/common/back.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open(this.src);}" onmousewheel="return imgzoom(this);" alt="" /></a><br />
在txtsetup.sif中加了两行,基本上搞定,比进入桌面后加载dummy.sys前进了一步,因为不用重启shell,但还是要插拔一次U盘。<br />
有没有办法不用插拔U盘,完成一次相当于插拔的动作,即弹出然后加载U盘。
<br />

在程序中加入以下代码,调用HT_Replug即可(参数为USB设备的ID)


#define DWORD_PTR DWORD
#define ULONG_PTR ULONG
#include <cfgmgr32.h>
#pragma comment(lib,"cfgmgr32.lib")

BOOL FindDevNode(DEVINST dnHere, PDEVINST dnResult, PCHAR partialName)
{
    if(0 == dnHere)
        return FALSE;

    DEVINST dnChild = 0;
    DEVINST dnSibling = 0;
    char deviceid[256];
   
    CONFIGRET cr=CM_Get_Device_ID(dnHere, deviceid, sizeof(deviceid), 0);
    if((CR_SUCCESS == cr) && (0 == strnicmp(deviceid, partialName, strlen(partialName))))
    {
        *dnResult = dnHere;
        return TRUE;
    }
   
    if(CR_SUCCESS == (cr = CM_Get_Child(&dnChild, dnHere, 0)))
        if(FindDevNode(dnChild, dnResult, partialName))
            return TRUE;

    if(CR_SUCCESS == (cr = CM_Get_Sibling(&dnSibling, dnHere, 0)))
        if(FindDevNode(dnSibling, dnResult, partialName))
            return TRUE;
   
    return FALSE;
}

BOOLEAN RestartDevice(
    IN HDEVINFO DeviceInfoSet,
    IN OUT PSP_DEVINFO_DATA DeviceInfoData
    )
{
    SP_PROPCHANGE_PARAMS params;
    SP_DEVINSTALL_PARAMS installParams;

    // for future compatibility; this will zero out the entire struct, rather
    // than just the fields which exist now
    memset(&params, 0, sizeof(SP_PROPCHANGE_PARAMS));

    // initialize the SP_CLASSINSTALL_HEADER struct at the beginning of the
    // SP_PROPCHANGE_PARAMS struct, so that SetupDiSetClassInstallParams will
    // work
    params.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER);
    params.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE;

    // initialize SP_PROPCHANGE_PARAMS such that the device will be stopped.
    params.StateChange = DICS_STOP;
    params.Scope       = DICS_FLAG_CONFIGSPECIFIC;
    params.HwProfile   = 0; // current profile

    char szBuf[512];
    // prepare for the call to SetupDiCallClassInstaller (to stop the device)
    if( !SetupDiSetClassInstallParams( DeviceInfoSet,
                                       DeviceInfoData,
                                       (PSP_CLASSINSTALL_HEADER) &params,
                                       sizeof(SP_PROPCHANGE_PARAMS)
        ) )
    {
       sprintf(szBuf,"in RestartDevice(): couldn't set the install parameters!\n"\
          "Error: %u\n",GetLastError());
       MessageBox(NULL,szBuf,"UMSAPI2K",MB_OK);
       return (FALSE);
    }

    // stop the device
    if( !SetupDiCallClassInstaller( DIF_PROPERTYCHANGE,
                                    DeviceInfoSet,
                                    DeviceInfoData )
        )
    {
        sprintf(szBuf,"in RestartDevice(): call to class installer (STOP) failed!\n"\
           "Error: %u\n",GetLastError());
        MessageBox(NULL,szBuf,"UMSAPI2K",MB_OK);
        return (FALSE);
    }

    // restarting the device
    params.StateChange = DICS_START;

    // prepare for the call to SetupDiCallClassInstaller (to stop the device)
    if( !SetupDiSetClassInstallParams( DeviceInfoSet,
                                       DeviceInfoData,
                                       (PSP_CLASSINSTALL_HEADER) &params,
                                       sizeof(SP_PROPCHANGE_PARAMS)
        ) )
    {
        sprintf(szBuf,"in RestartDevice(): couldn't set the install parameters!\n"\
           "Error: %u\n",GetLastError());
        MessageBox(NULL,szBuf,"UMSAPI2K",MB_OK);
        return (FALSE);
    }

    // restart the device
    if( !SetupDiCallClassInstaller( DIF_PROPERTYCHANGE,
                                    DeviceInfoSet,
                                    DeviceInfoData )
        )
    {
        sprintf(szBuf,"in RestartDevice(): call to class installer (START) failed!\n"\
           "Error: %u\n",GetLastError());
        MessageBox(NULL,szBuf,"UMSAPI2K",MB_OK);
        return (FALSE);
    }

    installParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS);

    // same as above, the call will succeed, but we still need to check status
    if( !SetupDiGetDeviceInstallParams( DeviceInfoSet,
                                        DeviceInfoData,
                                        &installParams )
        )
    {
        sprintf(szBuf,"in RestartDevice(): couldn't get the device install params!\n"\
            "Error: %u\n",GetLastError());
        MessageBox(NULL,szBuf,"UMSAPI2K",MB_OK);
        return (FALSE);
    }

    // to see if the machine needs to be rebooted
    if( installParams.Flags & DI_NEEDREBOOT )
    {
        return (FALSE);
    }

    // if we get this far, then the device has been stopped and restarted
    return (TRUE);
}

// BOOL stopDevice(char *szVen,char *szProd)
// {
//    char DEVICEID[64];
//    DEVINST dn = NULL;
//    sprintf(DEVICEID,"USB\\Vid_%s&Pid_%s",szVen,szProd);
//
//    if(CR_SUCCESS!=CM_Locate_DevNode(&dn,0,0))
//    {
//       MessageBox(NULL,"!CM_LocateDevNode fail!","UMSAPI2K",MB_OK);
//       return FALSE;
//    }
//
//    PNP_VETO_TYPE  type;
//    if(FindDevNode(dn, &dn, (PCHAR)DEVICEID))
//    {
//       char szVetoName[_MAX_PATH];
//       if(CR_SUCCESS!=CM_Request_Device_Eject(dn,&type,szVetoName,_MAX_PATH,0))
//       {
//          //AfxMessageBox("Remove fail!");
//          return FALSE;
//       }
//    }
//    return TRUE;
// }

BOOL HT_Replug(HWND hwnd,char *szVen,char *szProd)
{
   char DEVICEID[64];
   sprintf(DEVICEID,"USB\\Vid_%s&Pid_%s",szVen,szProd);

   GUID guid;
   DWORD dw;

   SetupDiClassGuidsFromName("HIDClass",&guid,1,&dw);
   HDEVINFO hInfo=SetupDiGetClassDevs(&guid,DEVICEID,hwnd,DIGCF_PRESENT);
   if(hInfo==INVALID_HANDLE_VALUE) return FALSE;

   BOOL bRet=TRUE;
   SP_DEVINFO_DATA devInfoData;
   devInfoData.cbSize=sizeof(SP_DEVINFO_DATA);
   for(int deviceIndex=0;
       SetupDiEnumDeviceInfo( hInfo, deviceIndex, &devInfoData );
       deviceIndex++)
   {
      if(!RestartDevice(hInfo,&devInfoData)) bRet=FALSE;
   }
   SetupDiDestroyDeviceInfoList( hInfo );
   return bRet;
}
作者: qdaijchf    时间: 2010-5-28 09:43
谢谢123!
在程序中加入代码,你的意思是用这段代码搞成一个EXE程序?
作者: qdaijchf    时间: 2010-5-28 12:10
从网上找了一个程序,已经全部搞定。
作者: netwinxp    时间: 2010-5-29 14:45
标题: 回复 #8 123 的帖子
你那个单片机的shell做得怎样了:)




欢迎光临 无忧启动论坛 (http://bbs.c3.wuyou.net/) Powered by Discuz! X3.3