Click here to Skip to main content
15,895,011 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionabout task manager Pin
Member 43990943-Sep-07 1:59
Member 43990943-Sep-07 1:59 
AnswerRe: about task manager Pin
chandu0043-Sep-07 2:25
chandu0043-Sep-07 2:25 
GeneralRe: about task manager Pin
Jerry Hammond4-Sep-07 20:24
Jerry Hammond4-Sep-07 20:24 
AnswerRe: about task manager Pin
Russell'3-Sep-07 3:13
Russell'3-Sep-07 3:13 
QuestionHow to get last window's hwnd Pin
josip cagalj3-Sep-07 1:45
josip cagalj3-Sep-07 1:45 
AnswerRe: How to get last window's hwnd Pin
Nishad S3-Sep-07 2:46
Nishad S3-Sep-07 2:46 
GeneralRe: How to get last window's hwnd [modified] Pin
josip cagalj3-Sep-07 21:52
josip cagalj3-Sep-07 21:52 
QuestionTDI Server Programme .... TdiBuildListen help Pin
barun_iit3-Sep-07 0:30
barun_iit3-Sep-07 0:30 
I have written an TDI server program, which is not able to accept any connection although listen succeeds. Given below my sample code. Please help me in figuring out where i am wrong or if possible suggest me for some good source link.

NTSTATUS
Listen(PFILE_OBJECT FileObject) //UINT Addr
{
NTSTATUS Status = STATUS_INSUFFICIENT_RESOURCES;
PIRP Irp;
IO_STATUS_BLOCK IoStatus = {0};
PDEVICE_OBJECT DeviceObject;

char cBuffer[256] = {0};
char ack[20] = "ok";

PTRANSPORT_ADDRESS pTransportAddress = (PTRANSPORT_ADDRESS)&cBuffer;


TDI_CONNECTION_INFORMATION RequestConnectionInfo = {0};
TDI_CONNECTION_INFORMATION ReturnConnectionInfo = {0};

KEVENT Event;

DbgPrint("Inside listen");
KeInitializeEvent(&Event, NotificationEvent, FALSE);
DeviceObject = IoGetRelatedDeviceObject(FileObject);

Irp = TdiBuildInternalDeviceControlIrp(TDI_LISTEN, DeviceObject, FileObject,
&Event, &IoStatus);
if (Irp == 0)
{
DbgPrint("TDI_LISTEN .... failed\n");
return STATUS_INSUFFICIENT_RESOURCES;
}

DbgPrint("TdiBuildInternalDeviceControl success");



RequestConnectionInfo.UserData = (PVOID) ack;
RequestConnectionInfo.UserDataLength = strlen(ack);

RequestConnectionInfo.Options = 0; //TDI_QUERY_ACCEPT;
RequestConnectionInfo.OptionsLength = sizeof(ULONG);

RequestConnectionInfo.RemoteAddress = NULL;
RequestConnectionInfo.RemoteAddressLength = 0;


DbgPrint("Before Delay");
delay(30);
TdiBuildListen(Irp, DeviceObject, FileObject, NULL, NULL, 0, &RequestConnectionInfo, &ReturnConnectionInfo);

DbgPrint("After TdiBuildListen");
Status = IoCallDriver(DeviceObject, Irp);

if (Status == STATUS_PENDING)
Status = KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); //UserMode

DbgPrint("Leaving TdiBuildListen");
return Status == STATUS_SUCCESS ? IoStatus.Status : Status;

}


/*
* accept
*/

NTSTATUS
Accept(PFILE_OBJECT FileObject)
{

/*
TA_IP_ADDRESS taIpAddress;
TDI_CONNECTION_INFORMATION tdiConnectionInformation;

RtlZeroMemory( &taIpAddress, sizeof( taIpAddress ) );
taIpAddress.TAAddressCount = 1;
taIpAddress.Address[ 0 ].AddressLength = TDI_ADDRESS_LENGTH_IP;
taIpAddress.Address[ 0 ].AddressType = TDI_ADDRESS_TYPE_IP;

RtlZeroMemory( &tdiConnectionInformation, sizeof( tdiConnectionInformation ));
tdiConnectionInformation.RemoteAddressLength = sizeof( taIpAddress );
tdiConnectionInformation.RemoteAddress = &taIpAddress;

*/

NTSTATUS Status = STATUS_INSUFFICIENT_RESOURCES;
PIRP Irp;
IO_STATUS_BLOCK IoStatus = {0};
PDEVICE_OBJECT DeviceObject;

char cBuffer[256] = {0};
PTDI_ADDRESS_IP pTdiAddressIp;
PTRANSPORT_ADDRESS pTransportAddress = (PTRANSPORT_ADDRESS)&cBuffer;


TDI_CONNECTION_INFORMATION RequestConnectionInfo = {0};
TDI_CONNECTION_INFORMATION ReturnConnectionInfo = {0};

KEVENT Event;


KeInitializeEvent(&Event, NotificationEvent, FALSE);
DeviceObject = IoGetRelatedDeviceObject(FileObject);

DbgPrint("Inside Accept");
DbgPrint("Before TdiBuildInternalDeviceControlIrp");
delay(25);

Irp = TdiBuildInternalDeviceControlIrp(TDI_ACCEPT, DeviceObject, FileObject,
&Event, &IoStatus);
if (Irp == 0)
{
DbgPrint("Failure in TdiBuildInternalDeviceControlIrp");
return STATUS_INSUFFICIENT_RESOURCES;
}

DbgPrint("After TdiBuildInternalDeviceControlIrp");


pTransportAddress->TAAddressCount = 1;
pTransportAddress->Address[0].AddressType = TDI_ADDRESS_TYPE_IP;
pTransportAddress->Address[0].AddressLength = TDI_ADDRESS_LENGTH_IP;

pTdiAddressIp = (TDI_ADDRESS_IP *)&pTransportAddress->Address[0].Address;

pTdiAddressIp->sin_port = HTONS(PORT); //* Example: 1494 = 0x05D6 (Little Endian) or 0xD605 (Big Endian)
pTdiAddressIp->in_addr = INETADDR(10,6,21,20); //* Example: 10.60.2.159 = 0A.3C.02.9F (Little Endian) or 9F.02.3C.0A (Big Endian)



RequestConnectionInfo.UserData = NULL;
RequestConnectionInfo.UserDataLength = 0;

RequestConnectionInfo.Options = 0;
RequestConnectionInfo.OptionsLength = 0;

RequestConnectionInfo.RemoteAddress =(PVOID)pTransportAddress;
RequestConnectionInfo.RemoteAddressLength = sizeof(PTRANSPORT_ADDRESS) + sizeof(TDI_ADDRESS_IP);


DbgPrint("Before TdiBuildAccept");
delay(25);

TdiBuildAccept(Irp, DeviceObject, FileObject, NULL, NULL, &RequestConnectionInfo, &ReturnConnectionInfo);

DbgPrint("After TdiBuildAccept");
delay(25);

Status = IoCallDriver(DeviceObject, Irp);

if (Status == STATUS_PENDING)
Status = KeWaitForSingleObject(&Event, UserRequest, KernelMode, FALSE, 0);

DbgPrint("Leaving Accept");
delay(25);

return Status == STATUS_SUCCESS ? IoStatus.Status : Status;

}



With thanks in advance,
barun

barun

QuestionHow to use SetItem() and GetItem() for ListCtrl having JPEG images? Pin
Atul233-Sep-07 0:15
Atul233-Sep-07 0:15 
AnswerRe: How to use SetItem() and GetItem() for ListCtrl having JPEG images? Pin
Nishad S3-Sep-07 1:41
Nishad S3-Sep-07 1:41 
GeneralRe: How to use SetItem() and GetItem() for ListCtrl having JPEG images? Pin
Atul233-Sep-07 1:55
Atul233-Sep-07 1:55 
GeneralRe: How to use SetItem() and GetItem() for ListCtrl having JPEG images? Pin
Nishad S3-Sep-07 2:44
Nishad S3-Sep-07 2:44 
QuestionImport dll to vc++ Pin
shakumar_222-Sep-07 23:56
shakumar_222-Sep-07 23:56 
AnswerRe: Import dll to vc++ Pin
chandu0043-Sep-07 0:01
chandu0043-Sep-07 0:01 
GeneralRe: Import dll to vc++ Pin
shakumar_223-Sep-07 0:56
shakumar_223-Sep-07 0:56 
AnswerRe: Import dll to vc++ Pin
Hamid_RT3-Sep-07 0:05
Hamid_RT3-Sep-07 0:05 
Questionhi Pin
Lakshmi_p2-Sep-07 23:47
Lakshmi_p2-Sep-07 23:47 
AnswerRe: hi Pin
baerten2-Sep-07 23:53
baerten2-Sep-07 23:53 
GeneralRe: hi Pin
Rajesh R Subramanian2-Sep-07 23:59
professionalRajesh R Subramanian2-Sep-07 23:59 
GeneralRe: hi Pin
Lakshmi_p3-Sep-07 0:37
Lakshmi_p3-Sep-07 0:37 
AnswerRe: hi Pin
Rajesh R Subramanian3-Sep-07 0:08
professionalRajesh R Subramanian3-Sep-07 0:08 
Questionabout HKEY_CLASSES_ROOT TypeLib Pin
George_George2-Sep-07 23:27
George_George2-Sep-07 23:27 
QuestionStack overflow while reading bamp image Pin
Maynka2-Sep-07 23:26
Maynka2-Sep-07 23:26 
AnswerRe: Stack overflow while reading bamp image Pin
chandu0042-Sep-07 23:48
chandu0042-Sep-07 23:48 
AnswerRe: Stack overflow while reading bamp image Pin
Russell'2-Sep-07 23:55
Russell'2-Sep-07 23:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.