1 /* 2 * COPYRIGHT: GPL, see COPYING in the top level directory 3 * PROJECT: ReactOS kernel 4 * FILE: drivers/base/kdvm/kdvbox.c 5 * PURPOSE: VBOX data exchange function for kdvbox 6 * PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org) 7 */ 8 9 #include "kdvm.h" 10 11 typedef struct 12 { 13 ULONG SendSize; 14 ULONG BufferSize; 15 } KDVBOX_SEND_HEADER, *PKDVBOX_SEND_HEADER; 16 17 typedef struct 18 { 19 ULONG ReceivedDataSize; 20 } KDVBOX_RECEIVE_HEADER, *PKDVBOX_RECEIVE_HEADER; 21 22 VOID 23 NTAPI 24 KdVmPrepareBuffer(VOID) 25 { 26 KdVmBufferPos = sizeof(KDVBOX_SEND_HEADER); 27 } 28 29 VOID 30 NTAPI 31 KdVmKdVmExchangeData( 32 _Out_ PVOID* ReceiveData, 33 _Out_ PULONG ReceiveDataSize) 34 { 35 PKDVBOX_SEND_HEADER SendHeader; 36 PKDVBOX_RECEIVE_HEADER ReceiveHeader; 37 38 /* Setup the send-header */ 39 SendHeader = (PKDVBOX_SEND_HEADER)KdVmDataBuffer; 40 SendHeader->SendSize = KdVmBufferPos - sizeof(KDVBOX_SEND_HEADER); 41 SendHeader->BufferSize = KDVM_BUFFER_SIZE; 42 43 //KdpDbgPrint("Sending buffer:\n"); 44 //KdVmDbgDumpBuffer(KdVmDataBuffer, KdVmBufferPos); 45 46 /* Do the data exchange */ 47 KdVmExchange((ULONG_PTR)KdVmBufferPhysicalAddress.QuadPart, 0); 48 49 /* Reset the buffer position */ 50 KdVmBufferPos = sizeof(KDVBOX_SEND_HEADER); 51 52 /* Get the receive-header and return information about the received data */ 53 ReceiveHeader = (PKDVBOX_RECEIVE_HEADER)KdVmDataBuffer; 54 *ReceiveData = KdVmDataBuffer + sizeof(KDVBOX_RECEIVE_HEADER); 55 *ReceiveDataSize = ReceiveHeader->ReceivedDataSize; 56 57 //KdpDbgPrint("got data:\n"); 58 //KdVmDbgDumpBuffer(KdVmDataBuffer, *ReceiveDataSize + sizeof(*ReceiveHeader)); 59 60 } 61