[x64]开源的ImagePrinter如何修改去支持X64环境

时间:2022-03-08 01:01:00
Virutal Image Printer这款开源的虚拟打印机,只支持32位系统。
怎么修改才能支持X64系统?

安装时,提示“ 没有找对打印机端口”。



Imageprinter其实是创建了个Print Monitor。安装Monitor是通过注册表来完成的,但是在x64中失败了。

有没有哪位兄弟有经验可以介绍一下呀?

可以有偿服务。

5 个解决方案

#1


有人来发下言么?
顶一顶

#2


重复利用一下

哪位达人帮忙看一下这段代码为什么不能控制网速


UINT GetPacketSize(PNDIS_PACKET pPacket, PACKET_TYPE_ENUM enumPacketType)
{
PNDIS_BUFFER NdisBuffer ;
UINT TotalPacketLength = 0;
UINT PhysicalBufferCount;
UINT BufferCount   ;

NdisQueryPacket(pPacket,  // NDIS_PACKET        
&PhysicalBufferCount,// 内存中的物理块数
&BufferCount,  // 多少个NDIS_BUFFER包
&NdisBuffer,         // 将返回第一个包
&TotalPacketLength  // 总共的包数据长度
);
switch(enumPacketType)
{
case PACKET_TYPE_SEND:
g_ulSend += TotalPacketLength;
break;
case PACKET_TYPE_RECV:
g_ulRecv += TotalPacketLength;
break;
}

if(g_ulSend > g_ulSeconds*MAX_SEND_SPEED || g_ulRecv > g_ulSeconds*MAX_RECV_SPEED)
{
KdPrint(("Thread suspends 500000 MircoSeconds...",ulMircoSecond));
LARGE_INTEGER timeout = RtlConvertLongToLargeInteger(-500000);
KeDelayExecutionThread(KernelMode,FALSE,&timeout);
KdPrint(("Thread is running again!\n"));
}

return TotalPacketLength;
}

VOID OnTimer(
    IN PDEVICE_OBJECT DeviceObject,
    IN PVOID Context)
{
DbgPrint("OnTimer: %d", g_ulSeconds);
g_ulSeconds++;
}

#3


这种方法可以用来安装打印机端口么?

Section "MainSection" SEC01
  SetOutPath "$INSTDIR"
  File "imgprinter.inf"
  SetOutPath "$INSTDIR\amd64"
  File "stdnames.gpd"
  File "imgprint.gpd"
  File "ddklocalmon.dll"
  File "ddklocalui.dll"

  SetOverwrite ifnewer
  SetOutPath "$SYSDIR"
  File "ddklocalmon.dll"
  File "ddklocalui.dll"
  File "monitor.inf"


WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Print\Monitors\ImagePrinter Port" "Driver" "ddklocalmon.dll"
  WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Print\Monitors\ImagePrinter Port\Ports" "ImagePrinter Port" ""
  
  
  SetOutPath "$INSTDIR"
  ExecWait 'rundll32 printui.dll,PrintUIEntry /dl /n "ImagePrinter" /q'
  ExecWait 'rundll32 printui.dll,PrintUIEntry /if /b "ImagePrinter" /f imgprinter.inf /r "ImagePrinter Port" /m "ImagePrinter"' 








[Version]
Signature="$Windows NT$"
Provider=%MS%
LayoutFile=ntprint.inf
ClassGUID={4D36E979-E325-11CE-BFC1-08002BE10318}
Class=Printer
DriverVer=01/15/2007

[Manufacturer]
"ITK"=ITK, NTamd64, NTia64


[ITK]
"ImagePrinter"      = NT5_OEMUNI


[ITK.NTamd64]
"ImagePrinter"      = NT5_OEMUNI

[ITK.NTia64]
"ImagePrinter"      = NT5_OEMUNI


[NT5_OEMUNI]
CopyFiles=@imgprint.gpd
CopyFiles=OEMUNI
CopyFiles=ExitDir
DataSection=UNIDRV_DATA
DataFile=imgprint.gpd
Include=NTPRINT.INF
Needs=UNIDRV.OEM

[SourceDisksFiles]
;new
;1 = %disk1%,,,
imgprint.gpd = 1,,,,,,,11,3
STDNAMES.GPD = 1,,,,,,,11,3

[DestinationDirs]
DefaultDestDir=66000

;old 
;ExitDir=11
;[ControlFlags]
;ExcludeFromSelect = 2369

[Strings]
PrinterClassName="Printers"
MS="ITK"

#4


帮你顶下,同求答案
64位系统可能需要64位编译的Port Monitor dll吧,我猜的
另外安装Monitor我是通过AddMonitor安装的,还有ImagePrinter端口的dll不是imgport吗?你为什么要安装DDK的ddklocalmon.dll?

#5


引用 4 楼 yzc1006 的回复:
帮你顶下,同求答案
64位系统可能需要64位编译的Port Monitor dll吧,我猜的
另外安装Monitor我是通过AddMonitor安装的,还有ImagePrinter端口的dll不是imgport吗?你为什么要安装DDK的ddklocalmon.dll?


呵呵,已经解决了,利用Imageprinter的代码是不行的,最终用的ddk力的localmon.


再利用下此贴,^_^
protocol.c ln1017
                Status = GetPacketSize(MyPacket, PACKET_TYPE_RECV, NDIS_STATUS_RESOURCES, pAdapt, TRUE);

                if(Status != NDIS_STATUS_PENDING)
                 {
                 NDIS_SET_PACKET_STATUS(MyPacket, NDIS_STATUS_RESOURCES);

                //
                // By setting NDIS_STATUS_RESOURCES, we also know that we can reclaim
                // this packet as soon as the call to NdisMIndicateReceivePacket
                // returns.
                //

if (pAdapt->MiniportHandle != NULL)
{

NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &MyPacket, 1);
}

//
// Reclaim the indicated packet. Since we had set its status
// to NDIS_STATUS_RESOURCES, we are guaranteed that protocols
// above are done with it.
//
NdisDprFreePacket(MyPacket);
                 }

ln1206
#if 0


ln1257
        NDIS_SET_PACKET_HEADER_SIZE(MyPacket, NDIS_GET_PACKET_HEADER_SIZE(Packet));

 Status = GetPacketSize(MyPacket, PACKET_TYPE_RECV, Status, pAdapt, TRUE);
 if(Status != NDIS_STATUS_PENDING)
 {
  NDIS_SET_PACKET_STATUS(MyPacket, Status);
        if (pAdapt->MiniportHandle != NULL)
        {
NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &MyPacket, 1);
        }

        //
        // Check if we had indicated up the packet with NDIS_STATUS_RESOURCES
        // NOTE -- do not use NDIS_GET_PACKET_STATUS(MyPacket) for this since
        // it might have changed! Use the value saved in the local variable.
        //
        if (Status == NDIS_STATUS_RESOURCES)
        {
            //
            // Our ReturnPackets handler will not be called for this packet.
            // We should reclaim it right here.
            //
            NdisDprFreePacket(MyPacket);
        }
 }


passthru.c ln577
NdisMSleep(100000);
pDataStru = CONTAINING_RECORD(request, MyDataStruct, ListEntry);  
pAdapt = (PADAPT)(pDataStru->AdapterContext);
packet = pDataStru->packet;  

switch (pDataStru->enmType)
{
case PACKET_TYPE_SEND:
DbgPrint(("SEND Delay"));
NdisMSendComplete(pAdapt->MiniportHandle,packet,pDataStru->Status);
break;
case PACKET_TYPE_RECV:
DbgPrint(("R cv Delay"));
NDIS_SET_PACKET_STATUS(packet, pDataStru->Status);
NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &(packet), 1);
break;
}

#1


有人来发下言么?
顶一顶

#2


重复利用一下

哪位达人帮忙看一下这段代码为什么不能控制网速


UINT GetPacketSize(PNDIS_PACKET pPacket, PACKET_TYPE_ENUM enumPacketType)
{
PNDIS_BUFFER NdisBuffer ;
UINT TotalPacketLength = 0;
UINT PhysicalBufferCount;
UINT BufferCount   ;

NdisQueryPacket(pPacket,  // NDIS_PACKET        
&PhysicalBufferCount,// 内存中的物理块数
&BufferCount,  // 多少个NDIS_BUFFER包
&NdisBuffer,         // 将返回第一个包
&TotalPacketLength  // 总共的包数据长度
);
switch(enumPacketType)
{
case PACKET_TYPE_SEND:
g_ulSend += TotalPacketLength;
break;
case PACKET_TYPE_RECV:
g_ulRecv += TotalPacketLength;
break;
}

if(g_ulSend > g_ulSeconds*MAX_SEND_SPEED || g_ulRecv > g_ulSeconds*MAX_RECV_SPEED)
{
KdPrint(("Thread suspends 500000 MircoSeconds...",ulMircoSecond));
LARGE_INTEGER timeout = RtlConvertLongToLargeInteger(-500000);
KeDelayExecutionThread(KernelMode,FALSE,&timeout);
KdPrint(("Thread is running again!\n"));
}

return TotalPacketLength;
}

VOID OnTimer(
    IN PDEVICE_OBJECT DeviceObject,
    IN PVOID Context)
{
DbgPrint("OnTimer: %d", g_ulSeconds);
g_ulSeconds++;
}

#3


这种方法可以用来安装打印机端口么?

Section "MainSection" SEC01
  SetOutPath "$INSTDIR"
  File "imgprinter.inf"
  SetOutPath "$INSTDIR\amd64"
  File "stdnames.gpd"
  File "imgprint.gpd"
  File "ddklocalmon.dll"
  File "ddklocalui.dll"

  SetOverwrite ifnewer
  SetOutPath "$SYSDIR"
  File "ddklocalmon.dll"
  File "ddklocalui.dll"
  File "monitor.inf"


WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Print\Monitors\ImagePrinter Port" "Driver" "ddklocalmon.dll"
  WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Print\Monitors\ImagePrinter Port\Ports" "ImagePrinter Port" ""
  
  
  SetOutPath "$INSTDIR"
  ExecWait 'rundll32 printui.dll,PrintUIEntry /dl /n "ImagePrinter" /q'
  ExecWait 'rundll32 printui.dll,PrintUIEntry /if /b "ImagePrinter" /f imgprinter.inf /r "ImagePrinter Port" /m "ImagePrinter"' 








[Version]
Signature="$Windows NT$"
Provider=%MS%
LayoutFile=ntprint.inf
ClassGUID={4D36E979-E325-11CE-BFC1-08002BE10318}
Class=Printer
DriverVer=01/15/2007

[Manufacturer]
"ITK"=ITK, NTamd64, NTia64


[ITK]
"ImagePrinter"      = NT5_OEMUNI


[ITK.NTamd64]
"ImagePrinter"      = NT5_OEMUNI

[ITK.NTia64]
"ImagePrinter"      = NT5_OEMUNI


[NT5_OEMUNI]
CopyFiles=@imgprint.gpd
CopyFiles=OEMUNI
CopyFiles=ExitDir
DataSection=UNIDRV_DATA
DataFile=imgprint.gpd
Include=NTPRINT.INF
Needs=UNIDRV.OEM

[SourceDisksFiles]
;new
;1 = %disk1%,,,
imgprint.gpd = 1,,,,,,,11,3
STDNAMES.GPD = 1,,,,,,,11,3

[DestinationDirs]
DefaultDestDir=66000

;old 
;ExitDir=11
;[ControlFlags]
;ExcludeFromSelect = 2369

[Strings]
PrinterClassName="Printers"
MS="ITK"

#4


帮你顶下,同求答案
64位系统可能需要64位编译的Port Monitor dll吧,我猜的
另外安装Monitor我是通过AddMonitor安装的,还有ImagePrinter端口的dll不是imgport吗?你为什么要安装DDK的ddklocalmon.dll?

#5


引用 4 楼 yzc1006 的回复:
帮你顶下,同求答案
64位系统可能需要64位编译的Port Monitor dll吧,我猜的
另外安装Monitor我是通过AddMonitor安装的,还有ImagePrinter端口的dll不是imgport吗?你为什么要安装DDK的ddklocalmon.dll?


呵呵,已经解决了,利用Imageprinter的代码是不行的,最终用的ddk力的localmon.


再利用下此贴,^_^
protocol.c ln1017
                Status = GetPacketSize(MyPacket, PACKET_TYPE_RECV, NDIS_STATUS_RESOURCES, pAdapt, TRUE);

                if(Status != NDIS_STATUS_PENDING)
                 {
                 NDIS_SET_PACKET_STATUS(MyPacket, NDIS_STATUS_RESOURCES);

                //
                // By setting NDIS_STATUS_RESOURCES, we also know that we can reclaim
                // this packet as soon as the call to NdisMIndicateReceivePacket
                // returns.
                //

if (pAdapt->MiniportHandle != NULL)
{

NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &MyPacket, 1);
}

//
// Reclaim the indicated packet. Since we had set its status
// to NDIS_STATUS_RESOURCES, we are guaranteed that protocols
// above are done with it.
//
NdisDprFreePacket(MyPacket);
                 }

ln1206
#if 0


ln1257
        NDIS_SET_PACKET_HEADER_SIZE(MyPacket, NDIS_GET_PACKET_HEADER_SIZE(Packet));

 Status = GetPacketSize(MyPacket, PACKET_TYPE_RECV, Status, pAdapt, TRUE);
 if(Status != NDIS_STATUS_PENDING)
 {
  NDIS_SET_PACKET_STATUS(MyPacket, Status);
        if (pAdapt->MiniportHandle != NULL)
        {
NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &MyPacket, 1);
        }

        //
        // Check if we had indicated up the packet with NDIS_STATUS_RESOURCES
        // NOTE -- do not use NDIS_GET_PACKET_STATUS(MyPacket) for this since
        // it might have changed! Use the value saved in the local variable.
        //
        if (Status == NDIS_STATUS_RESOURCES)
        {
            //
            // Our ReturnPackets handler will not be called for this packet.
            // We should reclaim it right here.
            //
            NdisDprFreePacket(MyPacket);
        }
 }


passthru.c ln577
NdisMSleep(100000);
pDataStru = CONTAINING_RECORD(request, MyDataStruct, ListEntry);  
pAdapt = (PADAPT)(pDataStru->AdapterContext);
packet = pDataStru->packet;  

switch (pDataStru->enmType)
{
case PACKET_TYPE_SEND:
DbgPrint(("SEND Delay"));
NdisMSendComplete(pAdapt->MiniportHandle,packet,pDataStru->Status);
break;
case PACKET_TYPE_RECV:
DbgPrint(("R cv Delay"));
NDIS_SET_PACKET_STATUS(packet, pDataStru->Status);
NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &(packet), 1);
break;
}