У меня тоже структура с указателем! И в тупике… как скрутить все в куче… ибо 32 разрядная программа вываливает кучу ошибок… разобрался что структура не заполняется!
и я так понял, что настройку ДМА адаптера можно оставить без изменения...
struct XDSP_DMA_BUFFER_PTRS
{
ULONG* DMABufferUserPtr1;
ULONG* DMABufferUserPtr2;
ULONG* DMABufferUserPtr3;
ULONG* DMABufferUserPtr4;
ULONG DMABufferPhysPtr1;
ULONG DMABufferPhysPtr2;
ULONG DMABufferPhysPtr3;
ULONG DMABufferPhysPtr4;
};
в дравере заполнение происходит в IOCTL запросе:
case MDMAI_DMA_SETUP://:
{
DbgPrint("enter MDMAI_DMA_SETUP:\n");
//ResetDevice(pdx);
// Verify DMA Adapter was created
HANDLE hEvent = *(HANDLE*)Irp->AssociatedIrp.SystemBuffer;
KdPrint((DRIVERNAME" - InterruptEventHandle = %0x.\n", hEvent));
if (pdx->DMAAdapter != NULL)
{
if (cbin < sizeof( XDSP_DMA_BUFFER_PTRS*))
{
status = STATUS_INVALID_PARAMETER;
break;
}
XDSP_DMA_BUFFER_PTRS* pBuffer = (XDSP_DMA_BUFFER_PTRS*)ExAllocatePool(NonPagedPool,cbout);
KdPrint((DRIVERNAME " — Size of XDSP_DMA_BUFFER_PTRS = %d \n", sizeof(XDSP_DMA_BUFFER_PTRS)));
if (pBuffer!=NULL)
{
if ((uDmaPhysAddr1 != 0)&&(uDmaPhysAddr2 != 0)&&(uDmaPhysAddr3 != 0)&&(uDmaPhysAddr4 != 0))
{
status = ObReferenceObjectByHandle( //Create reference to Event Object with Application
(HANDLE)hEvent, //Handle as Event Object
EVENT_MODIFY_STATE, //Can Modify Event Object state
*ExEventObjectType, //Type of event object. if File object - *IofileObjectType
KernelMode, //UserMode or KernelMode. If KernelMode - Set Previuos parameter to NULL
(PVOID *)&_kEvent, //Global pointer to Event object
NULL);
if(status != STATUS_SUCCESS)
{
KdPrint((DRIVERNAME " — ERROR Event Object \n"));
status = STATUS_INVALID_PARAMETER;
break;
}
if (!_kEvent)
{
KdPrint((DRIVERNAME " — ERROR SetKEvent \n"));
status = STATUS_INVALID_PARAMETER;
break;
}
KdPrint((DRIVERNAME " — Init Event Object... \n"));
pBuffer->DMABufferPhysPtr1 = uDmaPhysAddr1;
KdPrint((DRIVERNAME " - SHOW DMA pBuffer 1 ADDRESS IN START %Xh\n", pBuffer->DMABufferPhysPtr1));
pBuffer->DMABufferPhysPtr2 = uDmaPhysAddr2;
KdPrint((DRIVERNAME " - SHOW DMA pBuffer 2 ADDRESS IN START %Xh\n", pBuffer->DMABufferPhysPtr2));
pBuffer->DMABufferPhysPtr3 = uDmaPhysAddr3;
KdPrint((DRIVERNAME " - SHOW DMA pBuffer 3 ADDRESS IN START %Xh\n", pBuffer->DMABufferPhysPtr3));
pBuffer->DMABufferPhysPtr4 = uDmaPhysAddr4;
KdPrint((DRIVERNAME " - SHOW DMA pBuffer 4 ADDRESS IN START %Xh\n", pBuffer->DMABufferPhysPtr4));
pBuffer->DMABufferUserPtr1 = (ULONG*) MmMapLockedPagesSpecifyCache(DmaBufferMemory1, UserMode, MmCached, NULL, FALSE, NormalPagePriority);//DmaVirtualAddr1;
KdPrint((DRIVERNAME " - SHOW maps the physical pages 1 %Xh\n", (ULONG)pBuffer->DMABufferUserPtr1));
pBuffer->DMABufferUserPtr2 = (ULONG*) MmMapLockedPagesSpecifyCache(DmaBufferMemory2, UserMode, MmCached, NULL, FALSE, NormalPagePriority);//DmaVirtualAddr2;
KdPrint((DRIVERNAME " - SHOW maps the physical pages 2 %Xh\n", (ULONG)pBuffer->DMABufferUserPtr2));
pBuffer->DMABufferUserPtr3 = (ULONG*) MmMapLockedPagesSpecifyCache(DmaBufferMemory3, UserMode, MmCached, NULL, FALSE, NormalPagePriority);//DmaVirtualAddr3;
KdPrint((DRIVERNAME " - SHOW maps the physical pages 3 %Xh\n", (ULONG)pBuffer->DMABufferUserPtr3));
pBuffer->DMABufferUserPtr4 = (ULONG*) MmMapLockedPagesSpecifyCache(DmaBufferMemory4, UserMode, MmCached, NULL, FALSE, NormalPagePriority);//DmaVirtualAddr4;
KdPrint((DRIVERNAME " - SHOW maps the physical pages 4 %Xh\n", (ULONG)pBuffer->DMABufferUserPtr4));
info = sizeof(XDSP_DMA_BUFFER_PTRS);
KdPrint((DRIVERNAME " — Size of DATA = %d \n", info));
PVOID pInputBuffer = Irp->AssociatedIrp.SystemBuffer;
PVOID pOutputBuffer = NULL;
if(Irp->MdlAddress)
{
pOutputBuffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority);
}
if(pInputBuffer && pOutputBuffer)
{
DbgPrint("%i >= %i", cbout, info);
if(cbout >= info)
{
RtlCopyMemory(pOutputBuffer, pBuffer, info);
//pOutputBuffer = (PVOID) pBuffer;
status = STATUS_SUCCESS;
}else return STATUS_BUFFER_TOO_SMALL;
}
ExFreePool(pBuffer);// Free Buffer!
//удаляем обьект прерывания и порождаем новый?!!!
if (pdx->InterruptObject){
IoDisconnectInterrupt(pdx->InterruptObject);
pdx->InterruptObject = NULL;}
status = IoConnectInterrupt( &pdx->InterruptObject, (PKSERVICE_ROUTINE)OnInterrupt,
(PVOID)pdx, NULL, pdx->InterruptVector, pdx->InterruptIrql, pdx->InterruptIrql, pdx->InterruptMode, TRUE, pdx->InterruptAffinity, FALSE );
if( !NT_SUCCESS( status ) )
{
KdPrint( ( "IoConnectInterrupt failed! - %X\n", status ) );
status = STATUS_INVALID_PARAMETER;
break;
}else
{
KdPrint( ( "IoConnectInterrupt() Success\n" ) );
}
IoInitializeDpcRequest(fdo, (PIO_DPC_ROUTINE)DpcForIsr);
ResetDevice(pdx);
ULONG offset = 7*4;
WRITE_PORT_BUFFER_ULONG((PULONG)(pdx->portaddr + offset), (PULONG)&uDmaPhysAddr1, 1);
DeviceWasSetuped = 1;
status = STATUS_SUCCESS;
}else status = STATUS_INVALID_PARAMETER;
}else status = STATUS_INVALID_PARAMETER;
}else
{
KdPrint(("ERROR - DMA Adapter allocation failed\n"));
status = STATUS_INVALID_PARAMETER;
}
break;
}
а точнее
pBuffer->DMABufferPhysPtr1 = uDmaPhysAddr1;
pBuffer->DMABufferPhysPtr2 = uDmaPhysAddr2;
pBuffer->DMABufferPhysPtr3 = uDmaPhysAddr3;
pBuffer->DMABufferPhysPtr4 = uDmaPhysAddr4;
pBuffer->DMABufferUserPtr1 = (ULONG*) MmMapLockedPagesSpecifyCache(DmaBufferMemory1, UserMode, MmCached, NULL, FALSE, NormalPagePriority);//DmaVirtualAddr1;
pBuffer->DMABufferUserPtr2 = (ULONG*) MmMapLockedPagesSpecifyCache(DmaBufferMemory2, UserMode, MmCached, NULL, FALSE, NormalPagePriority);//DmaVirtualAddr2;
pBuffer->DMABufferUserPtr3 = (ULONG*) MmMapLockedPagesSpecifyCache(DmaBufferMemory3, UserMode, MmCached, NULL, FALSE, NormalPagePriority);//DmaVirtualAddr3;
pBuffer->DMABufferUserPtr4 = (ULONG*) MmMapLockedPagesSpecifyCache(DmaBufferMemory4, UserMode, MmCached, NULL, FALSE, NormalPagePriority);//DmaVirtualAddr4;
и дальше отправляем пользователю и запускаем плату на сбор данных, как показано в коде IOCTL запроса...
и получается не соответсвие размеров структур...
и еще Вы мне говорили, что необходимо заменить
RtlCopyMemory(pOutputBuffer, pBuffer, info);, я так и не понял на что?