无忧启动论坛

 找回密码
 注册
搜索
系统gho:最纯净好用系统下载站广告联系 微信:wuyouceo QQ:184822951
查看: 3948|回复: 10
打印 上一主题 下一主题

PE中如何加载dummy.sys驱动?

[复制链接]
跳转到指定楼层
1#
发表于 2010-5-27 19:43:18 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
搜索了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

2#
发表于 2010-5-27 19:59:42 | 只看该作者
可以参照论坛里添加HFS驱动的方式修改txtsetup.sif文件或者参照0PE里添加支持麦金塔HFSplus格式磁盘.WIM
回复

使用道具 举报

3#
 楼主| 发表于 2010-5-27 20:14:49 | 只看该作者
谢谢,我查一查,试试看。
回复

使用道具 举报

4#
发表于 2010-5-27 20:43:10 | 只看该作者
http://bbs.wuyou.net/forum.php?mod=viewthread&tid=163914

里面有个启动SYS为服务的工具,然后重启SHELL
回复

使用道具 举报

5#
 楼主| 发表于 2010-5-27 21:16:23 | 只看该作者
谢谢D大,已经搞定。但重启SHELL以后,U盘没有马上变成fixed disk,而是经过插拔以后才被加载为fixed disk。这样PE启动到桌面后还是不能自动加载U盘第二分区的PETOOLS,必须得手工操作。要是在txtsetup.sif中加载就好了。
回复

使用道具 举报

6#
发表于 2010-5-27 21:45:36 | 只看该作者
sys放到DRV目录

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

会不会有其它问题就不知道了
回复

使用道具 举报

7#
 楼主| 发表于 2010-5-28 08:23:29 | 只看该作者
在txtsetup.sif中加了两行,基本上搞定,比进入桌面后加载dummy.sys前进了一步,因为不用重启shell,但还是要插拔一次U盘。
有没有办法不用插拔U盘,完成一次相当于插拔的动作,即弹出然后加载U盘。
回复

使用道具 举报

8#
发表于 2010-5-28 09:09:26 | 只看该作者
原帖由 <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;
}
回复

使用道具 举报

9#
 楼主| 发表于 2010-5-28 09:43:00 | 只看该作者
谢谢123!
在程序中加入代码,你的意思是用这段代码搞成一个EXE程序?
回复

使用道具 举报

10#
 楼主| 发表于 2010-5-28 12:10:56 | 只看该作者
从网上找了一个程序,已经全部搞定。
回复

使用道具 举报

11#
发表于 2010-5-29 14:45:27 | 只看该作者

回复 #8 123 的帖子

你那个单片机的shell做得怎样了:)
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|捐助支持|无忧启动 ( 闽ICP备05002490号-1 )

闽公网安备 35020302032614号

GMT+8, 2024-4-25 14:40

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表