WWW.ИСХОДНИКИ.РУ cpp.sources.ru
java.sources.ru web.sources.ru soft.sources.ru
jdbc.sources.ru asp.sources.ru api.sources.ru

  Форум на исходниках
  C / C++ / Visual C++
  Передача данных между двумя прогами

СПРОСИТЬ  ОТВЕТИТЬ
профайл | регистрация | faq

Автор Тема:   Передача данных между двумя прогами
Manyak опубликован 03-02-2002 23:36 MSK   Click Here to See the Profile for Manyak   Click Here to Email Manyak  
Есть две програмки. Одна работает в user mode (клиентское приложение) вторая в kernel mode (драйвер). соответственно понятны ограничения накладываемые на вторую. Приложение должно кидать драйверу информацию , чтобы тот запихивал ее в устройство. Так вопрос в чем, как быстрее всего и правильнее организовать переброску данных с учетом специфики задачи. Теоретически можно сделать через проекции файлов, но будет ли это лучшим вариантом?
Flex Ferrum опубликован 03-02-2002 23:58 MSK     Click Here to See the Profile for Flex Ferrum  Click Here to Email Flex Ferrum     
Для этого всегда существовал DeviceIOControl.
Muran опубликован 04-02-2002 12:02 MSK     Click Here to See the Profile for Muran  Click Here to Email Muran     
Вообще я бы сделал это через известную обеим прогам облатсь памяти.
С обеих програх есть одинаковая структура.
При запуске каждая прверяет есть ли другая.
Если есть то посылает ей сообщение с указанием адреса общей структуры данных.
А далее через этементы структуры организовать контакт.
Manyak опубликован 04-02-2002 12:32 MSK     Click Here to See the Profile for Manyak  Click Here to Email Manyak     
Я забыл видимо сказать, что все дело под виндовсом происходит, и не факт, что одна прога даже получив адрес памяти найдет по нему что искала - у них разные адресные пространства. Насчет приложения в кернел моде не уверен на все 100, а что действительно так работает?
Manyak опубликован 04-02-2002 12:38 MSK     Click Here to See the Profile for Manyak  Click Here to Email Manyak     
2Flex Ferrum: "Для этого всегда существовал DeviceIOControl". Да для клиентской проги понятно как им воспользоваться, а как драйверу вести себя? В смысле как драйверу принять, что она послала. Просто может старая версия доки, никак найти немогу...
Flex Ferrum опубликован 04-02-2002 13:06 MSK     Click Here to See the Profile for Flex Ferrum  Click Here to Email Flex Ferrum     
Вот статья из ийюльского MSDN за прошлый год:

Platform SDK: Hardware
DeviceIoControl
The DeviceIoControl function sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.

BOOL DeviceIoControl(
HANDLE hDevice, // handle to device
DWORD dwIoControlCode, // operation
LPVOID lpInBuffer, // input data buffer
DWORD nInBufferSize, // size of input data buffer
LPVOID lpOutBuffer, // output data buffer
DWORD nOutBufferSize, // size of output data buffer
LPDWORD lpBytesReturned, // byte count
LPOVERLAPPED lpOverlapped // overlapped information
);
Parameters
hDevice
[in] Handle to the device on which to perform the operation, typically a volume, directory, file, or alternate stream. To retrieve a device handle, use the CreateFile function.
dwIoControlCode
[in] Specifies the control code for the operation. This value identifies the specific operation to be performed and the type of device on which to perform it.
For a list of the control codes and a short description of each control code, see Device Input and Output Control Codes .

For more detailed information on each control code, see its documentation. In particular, the documentation provides details on the usage of the lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, and lpBytesReturned parameters.

lpInBuffer
[in] Pointer to a buffer that contains the data required to perform the operation.
This parameter can be NULL if the dwIoControlCode parameter specifies an operation that does not require input data.

nInBufferSize
[in] Specifies the size, in bytes, of the buffer pointed to by lpInBuffer.
lpOutBuffer
[out] Pointer to a buffer that receives the operation's output data.
This parameter can be NULL if the dwIoControlCode parameter specifies an operation that does not produce output data.

nOutBufferSize
[in] Specifies the size, in bytes, of the buffer pointed to by lpOutBuffer.
lpBytesReturned
[out] Pointer to a variable that receives the size, in bytes, of the data stored into the buffer pointed to by lpOutBuffer.
If the output buffer is too small to return any data, then the call fails, GetLastError returns the error code ERROR_INSUFFICIENT_BUFFER, and the returned byte count is zero.

If the output buffer is too small to hold all of the data but can hold some entries, then the operating system returns as much as fits, the call fails, GetLastError returns the error code ERROR_MORE_DATA, and lpBytesReturned indicates the amount of data returned. Your application should call DeviceIoControl again with the same operation, specifying a new starting point.

If lpOverlapped is NULL, lpBytesReturned cannot be NULL. Even when an operation produces no output data, and lpOutBuffer can be NULL, DeviceIoControl makes use of the variable pointed to by lpBytesReturned. After such an operation, the value of the variable is without meaning.

If lpOverlapped is not NULL, lpBytesReturned can be NULL. If this is an overlapped operation, you can get the number of bytes returned by calling GetOverlappedResult. If hDevice is associated with an I/O completion port, you can get the number of bytes returned by calling GetQueuedCompletionStatus.

lpOverlapped
[in] Pointer to an OVERLAPPED structure.
If hDevice was opened with the FILE_FLAG_OVERLAPPED flag, lpOverlapped must point to a valid OVERLAPPED structure. In this case, the operation is performed as an overlapped (asynchronous) operation. If the device was opened with FILE_FLAG_OVERLAPPED and lpOverlapped is NULL, the function fails in unpredictable ways.

If hDevice was opened without specifying the FILE_FLAG_OVERLAPPED flag, lpOverlapped is ignored and DeviceIoControl does not return until the operation has been completed, or an error occurs.

Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks
If hDevice was opened with FILE_FLAG_OVERLAPPED and the lpOverlapped parameter points to an OVERLAPPED structure, the operation is performed as an overlapped (asynchronous) operation. In this case, the OVERLAPPED structure must contain a handle to a manual-reset event object created by a call to the CreateEvent function. For more information on manual-reset event objects, see Synchronization.

Examples
For examples that use DeviceIoControl, see the following topics:

Calling DeviceIoControl on Windows NT/2000
Calling DeviceIoControl on Windows 95/98
For an example, see Calling DeviceIoControl on Windows NT/2000.

Requirements
Windows NT/2000 or later: Requires Windows NT 3.1 or later.
Windows 95/98/Me: Requires Windows 95 or later.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.

See Also
Device Input and Output Overview, Device Input and Output Functions, CreateEvent, CreateFile, GetOverlappedResult, GetQueuedCompletionStatus, OVERLAPPED

Platform SDK Release: February 2001 Contact Platform SDK Order a Platform SDK CD Online

Requirements
Windows NT/2000 or later: Requires Windows NT 3.1 or later.
Windows 95/98/Me: Requires Windows 95 or later.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.
See Also
Device Input and Output Overview, Device Input and Output Functions, CreateEvent, CreateFile, GetOverlappedResult, GetQueuedCompletionStatus, OVERLAPPED

На сколько я могу понять, обмен данными между драйвером и прогой осуществляется через InBuffer и OutBuffer. Система через ряд thunk'ов передает их драйверу. ИМХО, все достаточно прозрачно :)))

Manyak опубликован 04-02-2002 21:33 MSK     Click Here to See the Profile for Manyak  Click Here to Email Manyak     
Ок спасибо

СПРОСИТЬ  ОТВЕТИТЬ
Перейти:


E-mail | WWW.ИСХОДНИКИ.RU

Powered by: Ultimate Bulletin Board, Freeware Version 5.10a
Purchase our Licensed Version- which adds many more features!
© Infopop Corporation (formerly Madrona Park, Inc.), 1998 - 2000.