a viatual com port driver

MessageI want to develop a virtual serial port driver,but has some questions,

  1. At first I call IoCreateDevice() to create a named L"\Device\VirCom" device,
    but when call
    status = IoCreateSymbolicLink (&dx->ifSymLinkName, // L"\Device\VirCom"
    &DevName); // L"\DosDevice\Com3"
    it failed,and the status is 0xC000003B,what’s wrong with me?

  2. Another question is : If can I call FindWindow() to find a windows ? and call SendMessage() to it?
    If can ,how to do?

Thanks in advanced!

Regards
misshome


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hi,
You need to pass the device name as UNICODE string to the functions
IoCreateDevice and IoCreateSymbolicLink.
Error 3D is an Invalid Parameter…
Convert the string L"\Device\VirCom" to unicode by using this function

IoCreateSymbolicLink( &uniWin32NameString, &uniNtNameString );

unicode of L"\Device\VirCom" is ur uniNtNameString
and
Unicode of L"\DosDevice\Com3" is ur uniWin32NameString

and pass the unicode string to the above functions.

Cheers,
-Naveen

On 07/12/01, “xxxxx@i-net.com.cn” wrote:

ÕâÊÇ MIME ¸ñʽµÄ¾ßÓкܶಿ·ÖÏûÏ¢¡£

------=_NextPart_000_0018_01C10AE2.5E14C270
Content-Type: text/plain;
charset=“gb2312”
Content-Transfer-Encoding: quoted-printable

MessageI want to develop a virtual serial port driver,but has some =
questions,

  1. At first I call IoCreateDevice() to create a named =
    L"\Device\VirCom" device,
    but when call=20
    status =3D IoCreateSymbolicLink (&dx->ifSymLinkName, // =
    L"\Device\VirCom"
    &DevName); // =
    L"\DosDevice\Com3"
    it failed,and the status is 0xC000003B,what’s wrong with me?

  2. Another question is : If can I call FindWindow() to find a windows ? =
    and call SendMessage() to it?
    If can ,how to do?

Thanks in advanced!

Regards
misshome


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

------=_NextPart_000_0018_01C10AE2.5E14C270
Content-Type: text/html;
charset=“gb2312”
Content-Transfer-Encoding: quoted-printable

Message

I want to develop a virtual =
> serial port driver,but has=20
> some questions,

 

1. At first I call =
> IoCreateDevice() to create a named=20
> L"\Device\VirCom" =
> device,

but when call =
>

=
> status =3D=20
> IoCreateSymbolicLink (&dx->ifSymLinkName, // L"> href=3D"file://\Device\VirCom">\Device\VirCom
&nb=
> sp;=20
> &=
> nbsp; &n=
> bsp; =20
> &DevName); // L”\DosDevice\Com3"
it failed,and the =
> status=20
> is 0xC000003B,what’s wrong with me?

 

2. Another question is : If can =
> I call FindWindow() to=20
> find a windows ? and call SendMessage() to it?

If can ,how to =
> do?

 

Thanks in advanced!

 

Regards

misshome

> size=3D2> 


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)

To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)

To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

------=_NextPart_000_0018_01C10AE2.5E14C270–

Yea,I have done, my code is the bellow:

UNICODE_STRING DevName;

RtlZeroMemory(&DevName, sizeof(UNICODE_STRING));

DevName.MaximumLength = 128 * sizeof(WCHAR);
DevName.Buffer = (unsigned short*)ExAllocatePool(PagedPool,
DevName.MaximumLength+sizeof(WCHAR));

if (DevName.Buffer == NULL) {
return STATUS_INSUFFICIENT_RESOURCES;
}

RtlZeroMemory(DevName.Buffer, DevName.MaximumLength + sizeof(WCHAR));
RtlAppendUnicodeToString(&DevName, L"\Device\VirCom");

status = IoCreateDevice (DriverObject,
sizeof(VIRCOM_DEVICE_EXTENSION),
&DevName,
FILE_DEVICE_SERIAL_PORT,
FILE_DEVICE_SECURE_OPEN,
TRUE,
&fdo);
if( !NT_SUCCESS(status))
return status;

// Remember fdo in our device extension
PWDM1_DEVICE_EXTENSION dx = (PWDM1_DEVICE_EXTENSION)fdo->DeviceExtension;
dx->fdo = fdo;
DebugPrint(“FDO is %x”,fdo);

dx->ifSymLinkName.MaximumLength = DevName.Length + sizeof(WCHAR);
dx->ifSymLinkName.Buffer = (unsigned short *)
ExAllocatePool(PagedPool, DevName.MaximumLength + sizeof(WCHAR));

if(!dx->ifSymLinkName.Buffer)
{
DebugPrint(“Error: Couldn’t allocate memory for
dx->ifSymLinkName!”);
status = STATUS_INSUFFICIENT_RESOURCES;
return status;
}

RtlZeroMemory(dx->ifSymLinkName.Buffer,dx->ifSymLinkName.MaximumLength);
RtlAppendUnicodeToString(&dx->ifSymLinkName, L"\DosDevices\Com");

status = IoCreateSymbolicLink (&dx->ifSymLinkName,
&DevName);

if (!NT_SUCCESS(status)) {
DebugPrint(“Error: IoCreateSymbolicLink Failed, ErrCode =
%x”,status);
IoDeleteDevice(fdo);
return status;
}

But it still not work, What wrong with me?

Thanks in advance!

Best regards
misshome


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

try this:

UNICODE_STRING DevName;
RtlInitUnicodeString(&DevName, L"\Device\VirCom");

status = IoCreateDevice (DriverObject,
sizeof(VIRCOM_DEVICE_EXTENSION),
&DevName,
FILE_DEVICE_SERIAL_PORT,
FILE_DEVICE_SECURE_OPEN,
TRUE,
&fdo);
if( !NT_SUCCESS(status))
return status;

// Remember fdo in our device extension
PWDM1_DEVICE_EXTENSION dx = (PWDM1_DEVICE_EXTENSION)fdo->DeviceExtension;
dx->fdo = fdo;
DebugPrint(“FDO is %x”,fdo);

RtlInitUnicodeString(&dx->ifSymLinkName, L"\DosDevices\Com");

RtlZeroMemory(dx->ifSymLinkName.Buffer,dx->ifSymLinkName.MaximumLength);
RtlAppendUnicodeToString(&dx->ifSymLinkName, L"\DosDevices\Com");

status = IoCreateSymbolicLink (&dx->ifSymLinkName,
&DevName);

if (!NT_SUCCESS(status)) {
DebugPrint(“Error: IoCreateSymbolicLink Failed, ErrCode =
%x”,status);
IoDeleteDevice(fdo);
return status;
}

----- Original Message -----
From:
To: “NT Developers Interest List”
Sent: Thursday, July 12, 2001 4:57 PM
Subject: [ntdev] Re: a viatual com port driver

> Yea,I have done, my code is the bellow:
>
> UNICODE_STRING DevName;
>
> RtlZeroMemory(&DevName, sizeof(UNICODE_STRING));
>
> DevName.MaximumLength = 128 * sizeof(WCHAR);
> DevName.Buffer = (unsigned short*)ExAllocatePool(PagedPool,
> DevName.MaximumLength+sizeof(WCHAR));
>
>
> if (DevName.Buffer == NULL) {
> return STATUS_INSUFFICIENT_RESOURCES;
> }
>
> RtlZeroMemory(DevName.Buffer, DevName.MaximumLength + sizeof(WCHAR));
> RtlAppendUnicodeToString(&DevName, L"\Device\VirCom");
>
> status = IoCreateDevice (DriverObject,
> sizeof(VIRCOM_DEVICE_EXTENSION),
> &DevName,
> FILE_DEVICE_SERIAL_PORT,
> FILE_DEVICE_SECURE_OPEN,
> TRUE,
> &fdo);
> if( !NT_SUCCESS(status))
> return status;
>
> // Remember fdo in our device extension
> PWDM1_DEVICE_EXTENSION dx = (PWDM1_DEVICE_EXTENSION)fdo->DeviceExtension;
> dx->fdo = fdo;
> DebugPrint(“FDO is %x”,fdo);
>
>
> dx->ifSymLinkName.MaximumLength = DevName.Length + sizeof(WCHAR);
> dx->ifSymLinkName.Buffer = (unsigned short )
> ExAllocatePool(PagedPool, DevName.MaximumLength + sizeof(WCHAR));
>
>
> if(!dx->ifSymLinkName.Buffer)
> {
> DebugPrint(“Error: Couldn’t allocate memory for
> dx->ifSymLinkName!”);
> status = STATUS_INSUFFICIENT_RESOURCES;
> return status;
> }
>
> RtlZeroMemory(dx->ifSymLinkName.Buffer,dx->ifSymLinkName.MaximumLength);
> RtlAppendUnicodeToString(&dx->ifSymLinkName, L"\DosDevices\Com");
>
> status = IoCreateSymbolicLink (&dx->ifSymLinkName,
> &DevName);
>
> if (!NT_SUCCESS(status)) {
> DebugPrint(“Error: IoCreateSymbolicLink Failed, ErrCode =
> %x”,status);
> IoDeleteDevice(fdo);
> return status;
> }
>
> But it still not work, What wrong with me?
>
> Thanks in advance!
>
> Best regards
> misshome
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@genius-soft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
???y˫???+.n?+???u?ڲ˛??^r
D???kN???r??zǧu??jy???^j???ׯ??? 0?j?b??(??(

Xuy and Wang get the donut. Naveen you gotta study a little bit more.

Ya gotta be able to spell folks. I can’t count the number of times I’ve seen
the same question posted, but this time I see at least 1 answer that
concatenated the same misspelling. It is “DosDevices”, and NOT “DosDevice”.

Gary G. Little
Staff Engineer
Broadband Storage, Inc.
xxxxx@Broadstor.com
xxxxx@inland.net

-----Original Message-----
From: xuye [mailto:xxxxx@genius-soft.com]
Sent: Thursday, July 12, 2001 3:56 AM
To: NT Developers Interest List
Subject: [ntdev] Re: a viatual com port driver

try this:

UNICODE_STRING DevName;
RtlInitUnicodeString(&DevName, L"\Device\VirCom");

status = IoCreateDevice (DriverObject,
sizeof(VIRCOM_DEVICE_EXTENSION),
&DevName,
FILE_DEVICE_SERIAL_PORT,
FILE_DEVICE_SECURE_OPEN,
TRUE,
&fdo);
if( !NT_SUCCESS(status))
return status;

// Remember fdo in our device extension
PWDM1_DEVICE_EXTENSION dx = (PWDM1_DEVICE_EXTENSION)fdo->DeviceExtension;
dx->fdo = fdo;
DebugPrint(“FDO is %x”,fdo);

RtlInitUnicodeString(&dx->ifSymLinkName, L"\DosDevices\Com");

RtlZeroMemory(dx->ifSymLinkName.Buffer,dx->ifSymLinkName.MaximumLength);
RtlAppendUnicodeToString(&dx->ifSymLinkName, L"\DosDevices\Com");

status = IoCreateSymbolicLink (&dx->ifSymLinkName,
&DevName);

if (!NT_SUCCESS(status)) {
DebugPrint(“Error: IoCreateSymbolicLink Failed, ErrCode =
%x”,status);
IoDeleteDevice(fdo);
return status;
}

----- Original Message -----
From:
To: “NT Developers Interest List”
Sent: Thursday, July 12, 2001 4:57 PM
Subject: [ntdev] Re: a viatual com port driver

> Yea,I have done, my code is the bellow:
>
> UNICODE_STRING DevName;
>
> RtlZeroMemory(&DevName, sizeof(UNICODE_STRING));
>
> DevName.MaximumLength = 128 * sizeof(WCHAR);
> DevName.Buffer = (unsigned short*)ExAllocatePool(PagedPool,
> DevName.MaximumLength+sizeof(WCHAR));
>
>
> if (DevName.Buffer == NULL) {
> return STATUS_INSUFFICIENT_RESOURCES;
> }
>
> RtlZeroMemory(DevName.Buffer, DevName.MaximumLength + sizeof(WCHAR));
> RtlAppendUnicodeToString(&DevName, L"\Device\VirCom");
>
> status = IoCreateDevice (DriverObject,
> sizeof(VIRCOM_DEVICE_EXTENSION),
> &DevName,
> FILE_DEVICE_SERIAL_PORT,
> FILE_DEVICE_SECURE_OPEN,
> TRUE,
> &fdo);
> if( !NT_SUCCESS(status))
> return status;
>
> // Remember fdo in our device extension
> PWDM1_DEVICE_EXTENSION dx = (PWDM1_DEVICE_EXTENSION)fdo->DeviceExtension;
> dx->fdo = fdo;
> DebugPrint(“FDO is %x”,fdo);
>
>
> dx->ifSymLinkName.MaximumLength = DevName.Length + sizeof(WCHAR);
> dx->ifSymLinkName.Buffer = (unsigned short *)
> ExAllocatePool(PagedPool, DevName.MaximumLength + sizeof(WCHAR));
>
>
> if(!dx->ifSymLinkName.Buffer)
> {
> DebugPrint(“Error: Couldn’t allocate memory for
> dx->ifSymLinkName!”);
> status = STATUS_INSUFFICIENT_RESOURCES;
> return status;
> }
>
>
RtlZeroMemory(dx->ifSymLinkName.Buffer,dx->ifSymLinkName.MaximumLength);
> RtlAppendUnicodeToString(&dx->ifSymLinkName, L"\DosDevices\Com");
>
> status = IoCreateSymbolicLink (&dx->ifSymLinkName,
> &DevName);
>
> if (!NT_SUCCESS(status)) {
> DebugPrint(“Error: IoCreateSymbolicLink Failed, ErrCode =
> %x”,status);
> IoDeleteDevice(fdo);
> return status;
> }
>
> But it still not work, What wrong with me?
>
> Thanks in advance!
>
> Best regards
> misshome
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@genius-soft.com
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
b‹š­ç.®·§¶\¬¹??Þv?µ×¯j?ŠÛeyºèi?¢·(?.žË›±Êâm?Ö›•©äzf¢–?y«Þž×^¿~w?b²Û(²·(


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com