kz丶cn 发表于 2016-5-2 21:34:07

求助,关于"地下加载驱动"中使用AddPrintfDriver加载驱动

我自己实现了下
函数返回成功了,但驱动没有加载起来,还需要干什么吗?
我下了一个HP的驱动
//#define DRIVERPATH "C:\\Windows\\System32\\spool\\drivers\\W32X86\\NullFilter.sys"
//#define DATAFILEPATH "C:\\Windows\\System32\\spool\\drivers\\W32X86\\hpi01111.gpd"
//#define CONFIGFILEPATH "C:\\Windows\\System32\\spool\\drivers\\W32X86\\hpiPIboe.dll"
//#define HELPPATH "C:\\Windows\\System32\\spool\\drivers\\W32X86\\UNIDRV.DLL"
//#define INFPATH "C:\\Windows\\System32\\spool\\drivers\\W32X86\\hpi1boeh.inf"

void LoadTest()
{
        DRIVER_INFO_3A DInfo;

        char lpDriverPath;
        char lpBuffer;
        DWORD uSize=0;


        int returnval = GetPrinterDriverDirectory(NULL,NULL,1,(LPBYTE)lpBuffer,MAX_PATH,&uSize);
        printf("%S\n",lpBuffer);

        /*strcpy_s(lpDriverPath,lpBuffer);
        strcat_s(lpDriverPath,"\\NullFilter.sys");
        printf("%s\n",lpDriverPath);

        char lpDataFilePath;
        strcpy_s(lpDataFilePath,lpBuffer);
        strcat_s(lpDataFilePath,"\\hpi01111.gpd");
        printf("%s\n",lpDataFilePath);

        char lpConfigFilePath;
        strcpy_s(lpConfigFilePath,lpBuffer);
        strcat_s(lpConfigFilePath,"\\hpiPIboe.dll");
        printf("%s\n",lpConfigFilePath);

        char lpHelpFilePath;
        strcpy_s(lpHelpFilePath,lpBuffer);
        strcat_s(lpHelpFilePath,"\\UNIDRV.DLL");
        printf("%s\n",lpHelpFilePath);*/

        ZeroMemory(&DInfo, sizeof(DRIVER_INFO_3A));

        DInfo.cVersion=0x03;
        DInfo.pName = "HP Designjet T7100 Mono HPGL2";
        DInfo.pEnvironment = NULL;
        DInfo.pDriverPath = DRIVERPATH;
        DInfo.pDataFile = DATAFILEPATH;
        DInfo.pConfigFile = CONFIGFILEPATH;
        DInfo.pHelpFile = HELPPATH;
        DInfo.pMonitorName = NULL;
        DInfo.pDependentFiles = NULL;
        DInfo.pDefaultDataType = "RAW";


        int returnvalue = AddPrinterDriver(NULL,3,(LPBYTE)&DInfo);
        if(InstallPrinterDriverFromPackageA(NULL,INFPATH,"NullFilter.sys",NULL,IPDFP_COPY_ALL_FILES) == S_OK)
        {
                printf("ok!\n");
        }
        //printf("error code : 0x%x\n",GetLastError());
        if(returnval == 0)
        {
                printf("faild!----code:0x%x\n",GetLastError());
        }else
        {
                printf("success!\n");
        }

}

kz丶cn 发表于 2016-5-2 21:36:12

忽略
InstallPrinterDriverFromPackageA
后面写上去的

Tesla.Angela 发表于 2016-5-4 17:57:08

哈哈,这个我也只是看到过思路,自己没实践过。
页: [1]
查看完整版本: 求助,关于"地下加载驱动"中使用AddPrintfDriver加载驱动