Quick Basic question

Hi,

Can we log a message in event log while holding a spin-lock?

Thanks,
Sunil

I checked MSDN it seems “IoWriteErrorLogEntry” can be called at dispatch
level. But I am getting a bsod while trying to log a message to event log
with error IRQL_NOT_LESS_OR_EQUAL. I am holding a spin lock while calling
IoWriteErrorLogEntry.

On Sat, Aug 27, 2011 at 11:05 PM, Sunil Patil wrote:

> Hi,
>
> Can we log a message in event log while holding a spin-lock?
>
> Thanks,
> Sunil
>

Are you doing an IoAllocateErrorLogEntry on the same path? Do you have
strings or data that you are copying into the packet? If so are they
all non-paged data?

Don Burn
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

“Sunil Patil” wrote in message news:xxxxx@ntdev:

> I checked MSDN it seems “IoWriteErrorLogEntry” can be called at dispatch
> level. But I am getting a bsod while trying to log a message to event log
> with error IRQL_NOT_LESS_OR_EQUAL. I am holding a spin lock while calling
> IoWriteErrorLogEntry.
>
>
> On Sat, Aug 27, 2011 at 11:05 PM, Sunil Patil wrote:
>
> > Hi,
> >
> > Can we log a message in event log while holding a spin-lock?
> >
> > Thanks,
> > Sunil
> >

Yes they are all non-paged pool data. But I am converting some of them to
wide char using function RtlStringCbPrintfExW while holding spin lock. I
think this is not allowed.

On Sat, Aug 27, 2011 at 11:38 PM, Don Burn wrote:

> Are you doing an IoAllocateErrorLogEntry on the same path? Do you have
> strings or data that you are copying into the packet? If so are they all
> non-paged data?
>
>
> Don Burn
> Windows Filesystem and Driver Consulting
> Website: http://www.windrvr.com
> Blog: http://msmvps.com/blogs/ WinDrvr http:
>
>
>
>
>
> “Sunil Patil” wrote in message news:xxxxx@ntdev:
>
>
> I checked MSDN it seems “IoWriteErrorLogEntry” can be called at dispatch
>> level. But I am getting a bsod while trying to log a message to event log
>> with error IRQL_NOT_LESS_OR_EQUAL. I am holding a spin lock while calling
>> IoWriteErrorLogEntry.
>>
>>
>> On Sat, Aug 27, 2011 at 11:05 PM, Sunil Patil wrote:
>>
>> > Hi,
>> >
>> > Can we log a message in event log while holding a spin-lock?
>> >
>> > Thanks,
>> > Sunil
>> >
>>
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.
cfm?name=ListServerhttp:
></http:></http:>

Is there any equivalent function to convert to wide char dispatch level?

Thanks,
Sunil

On Sat, Aug 27, 2011 at 11:44 PM, Sunil Patil wrote:

> Yes they are all non-paged pool data. But I am converting some of them to
> wide char using function RtlStringCbPrintfExW while holding spin lock. I
> think this is not allowed.
>
>
> On Sat, Aug 27, 2011 at 11:38 PM, Don Burn wrote:
>
>> Are you doing an IoAllocateErrorLogEntry on the same path? Do you have
>> strings or data that you are copying into the packet? If so are they all
>> non-paged data?
>>
>>
>> Don Burn
>> Windows Filesystem and Driver Consulting
>> Website: http://www.windrvr.com
>> Blog: http://msmvps.com/blogs/ WinDrvr http:
>>
>>
>>
>>
>>
>> “Sunil Patil” wrote in message news:xxxxx@ntdev:
>>
>>
>> I checked MSDN it seems “IoWriteErrorLogEntry” can be called at dispatch
>>> level. But I am getting a bsod while trying to log a message to event log
>>> with error IRQL_NOT_LESS_OR_EQUAL. I am holding a spin lock while calling
>>> IoWriteErrorLogEntry.
>>>
>>>
>>> On Sat, Aug 27, 2011 at 11:05 PM, Sunil Patil wrote:
>>>
>>> > Hi,
>>> >
>>> > Can we log a message in event log while holding a spin-lock?
>>> >
>>> > Thanks,
>>> > Sunil
>>> >
>>>
>>
>>
>> —
>> NTDEV is sponsored by OSR
>>
>> For our schedule of WDF, WDM, debugging and other seminars visit:
>> http://www.osr.com/seminars
>>
>> To unsubscribe, visit the List Server section of OSR Online at
>> http://www.osronline.com/page.
cfm?name=ListServerhttp:
>>
>
></http:></http:>

No, the required data structures are pageable. You could do a blind/dumb expansion of the code points to 16 bits if this is just for debugging purposes, e.g. debug prints.

Best not to do that for production code though as non-ascii text would be trashed.

  • S (MSFT)

From: Sunil Patil
Sent: Saturday, August 27, 2011 11:22
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Quick Basic question

Is there any equivalent function to convert to wide char dispatch level?

Thanks,
Sunil

On Sat, Aug 27, 2011 at 11:44 PM, Sunil Patil > wrote:
Yes they are all non-paged pool data. But I am converting some of them to wide char using function RtlStringCbPrintfExW while holding spin lock. I think this is not allowed.

On Sat, Aug 27, 2011 at 11:38 PM, Don Burn > wrote:
Are you doing an IoAllocateErrorLogEntry on the same path? Do you have strings or data that you are copying into the packet? If so are they all non-paged data?

Don Burn
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

“Sunil Patil” > wrote in message news:xxxxx@ntdev:

I checked MSDN it seems “IoWriteErrorLogEntry” can be called at dispatch
level. But I am getting a bsod while trying to log a message to event log
with error IRQL_NOT_LESS_OR_EQUAL. I am holding a spin lock while calling
IoWriteErrorLogEntry.

On Sat, Aug 27, 2011 at 11:05 PM, Sunil Patil > wrote:

> Hi,
>
> Can we log a message in event log while holding a spin-lock?
>
> Thanks,
> Sunil
>


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

— NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

This may be a dumb question. My requirement is I need to print ULONG or
ULONGLONG number in event log (at dispatch level), for which I use WCHAR
array of size 20, copy the number ULONG/ULONGLONG in this buffer and pass it
as input to the logging function.

Given that I cannot use WCHAR, is there any simple thing that I can do here
like:

  • instead of WCHAR use CHAR (not sure if possible)

Else in the worst case I will have to drop the event log messages.

Thanks,
Sunil

On Sun, Aug 28, 2011 at 12:24 AM, Skywing wrote:

> No, the required data structures are pageable. You could do a blind/dumb
> expansion of the code points to 16 bits if this is just for debugging
> purposes, e.g. debug prints.
>
> Best not to do that for production code though as non-ascii text would be
> trashed.
>
> - S (MSFT)
> ------------------------------
> From: Sunil Patil
> Sent: Saturday, August 27, 2011 11:22
> To: Windows System Software Devs Interest List
> Subject: Re: [ntdev] Quick Basic question
>
> Is there any equivalent function to convert to wide char dispatch level?
>
> Thanks,
> Sunil
>
>
> On Sat, Aug 27, 2011 at 11:44 PM, Sunil Patil wrote:
>
>> Yes they are all non-paged pool data. But I am converting some of them to
>> wide char using function RtlStringCbPrintfExW while holding spin lock. I
>> think this is not allowed.
>>
>>
>> On Sat, Aug 27, 2011 at 11:38 PM, Don Burn wrote:
>>
>>> Are you doing an IoAllocateErrorLogEntry on the same path? Do you have
>>> strings or data that you are copying into the packet? If so are they all
>>> non-paged data?
>>>
>>>
>>> Don Burn
>>> Windows Filesystem and Driver Consulting
>>> Website: http://www.windrvr.com
>>> Blog: http://msmvps.com/blogs/ WinDrvrhttp:
>>>
>>>
>>>
>>>
>>>
>>> “Sunil Patil” wrote in message news:xxxxx@ntdev:
>>>
>>>
>>> I checked MSDN it seems “IoWriteErrorLogEntry” can be called at dispatch
>>>> level. But I am getting a bsod while trying to log a message to event
>>>> log
>>>> with error IRQL_NOT_LESS_OR_EQUAL. I am holding a spin lock while
>>>> calling
>>>> IoWriteErrorLogEntry.
>>>>
>>>>
>>>> On Sat, Aug 27, 2011 at 11:05 PM, Sunil Patil
>>>> wrote:
>>>>
>>>> > Hi,
>>>> >
>>>> > Can we log a message in event log while holding a spin-lock?
>>>> >
>>>> > Thanks,
>>>> > Sunil
>>>> >
>>>>
>>>
>>>
>>> —
>>> NTDEV is sponsored by OSR
>>>
>>> For our schedule of WDF, WDM, debugging and other seminars visit:
>>> http://www.osr.com/seminars
>>>
>>> To unsubscribe, visit the List Server section of OSR Online at
>>> http://www.osronline.com/page.
cfm?name=ListServerhttp:
>>>
>>
>>
> — NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and
> other seminars visit: http://www.osr.com/seminars To unsubscribe, visit
> the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
></http:></http:>

You could write your own conversion function, for this one. Or can you
just put the data in the binary data for the event log entry?

Don Burn
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

“Sunil Patil” wrote in message news:xxxxx@ntdev:

> This may be a dumb question. My requirement is I need to print ULONG or
> ULONGLONG number in event log (at dispatch level), for which I use WCHAR
> array of size 20, copy the number ULONG/ULONGLONG in this buffer and pass it
> as input to the logging function.
>
> Given that I cannot use WCHAR, is there any simple thing that I can do here
> like:
> - instead of WCHAR use CHAR (not sure if possible)
>
> Else in the worst case I will have to drop the event log messages.
>
> Thanks,
> Sunil
>
> On Sun, Aug 28, 2011 at 12:24 AM, Skywing wrote:
>
> > No, the required data structures are pageable. You could do a blind/dumb
> > expansion of the code points to 16 bits if this is just for debugging
> > purposes, e.g. debug prints.
> >
> > Best not to do that for production code though as non-ascii text would be
> > trashed.
> >
> > - S (MSFT)
> > ------------------------------
> > From: Sunil Patil
> > Sent: Saturday, August 27, 2011 11:22
> > To: Windows System Software Devs Interest List
> > Subject: Re: [ntdev] Quick Basic question
> >
> > Is there any equivalent function to convert to wide char dispatch level?
> >
> > Thanks,
> > Sunil
> >
> >
> > On Sat, Aug 27, 2011 at 11:44 PM, Sunil Patil wrote:
> >
> >> Yes they are all non-paged pool data. But I am converting some of them to
> >> wide char using function RtlStringCbPrintfExW while holding spin lock. I
> >> think this is not allowed.
> >>
> >>
> >> On Sat, Aug 27, 2011 at 11:38 PM, Don Burn wrote:
> >>
> >>> Are you doing an IoAllocateErrorLogEntry on the same path? Do you have
> >>> strings or data that you are copying into the packet? If so are they all
> >>> non-paged data?
> >>>
> >>>
> >>> Don Burn
> >>> Windows Filesystem and Driver Consulting
> >>> Website: http://www.windrvr.com
> >>> Blog: http://msmvps.com/blogs/ WinDrvrhttp:
> >>>
> >>>
> >>>
> >>>
> >>>
> >>> “Sunil Patil” wrote in message news:xxxxx@ntdev:
> >>>
> >>>
> >>> I checked MSDN it seems “IoWriteErrorLogEntry” can be called at dispatch
> >>>> level. But I am getting a bsod while trying to log a message to event
> >>>> log
> >>>> with error IRQL_NOT_LESS_OR_EQUAL. I am holding a spin lock while
> >>>> calling
> >>>> IoWriteErrorLogEntry.
> >>>>
> >>>>
> >>>> On Sat, Aug 27, 2011 at 11:05 PM, Sunil Patil
> >>>> wrote:
> >>>>
> >>>> > Hi,
> >>>> >
> >>>> > Can we log a message in event log while holding a spin-lock?
> >>>> >
> >>>> > Thanks,
> >>>> > Sunil
> >>>> >
> >>>>
> >>>
> >>>
> >>> —
> >>> NTDEV is sponsored by OSR
> >>>
> >>> For our schedule of WDF, WDM, debugging and other seminars visit:
> >>> http://www.osr.com/seminars
> >>>
> >>> To unsubscribe, visit the List Server section of OSR Online at
> >>> http://www.osronline.com/page.
cfm?name=ListServerhttp:
> >>>
> >>
> >>
> > — NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and
> > other seminars visit: http://www.osr.com/seminars To unsubscribe, visit
> > the List Server section of OSR Online at
> > http://www.osronline.com/page.cfm?name=ListServer
> >
> > —
> > NTDEV is sponsored by OSR
> >
> > For our schedule of WDF, WDM, debugging and other seminars visit:
> > http://www.osr.com/seminars
> >
> > To unsubscribe, visit the List Server section of OSR Online at
> > http://www.osronline.com/page.cfm?name=ListServer
> ></http:></http:>

Sounds like a job for… A Logging Thread!

Peter
OSR

Of course, this does add the extra complexities re: making sure log writes get throttled and don’t take all available memory if you are receiving frequent events. Tred cautiously.

  • S (MSFT)

-----Original Message-----
From: xxxxx@osr.com
Sent: Saturday, August 27, 2011 13:29
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Quick Basic question

Sounds like a job for… A Logging Thread!

Peter
OSR


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Hi Don,

I am writing my own conversion function for this. I have code like
following:

HexDigit = UNum % 16;
if (HexDigit <= 9) {
WStr[Size] = L’0’ + HexDigit; // Step 1
} else {
WStr[Size] = L’a’ + (HexDigit - 10); // Step 2
}

I am getting compilation error at step 1 and 2. I checked some sites which
say that we must use “btowc” for converting char int to wchar wint. Is there
any kernel equivalent function for this or a way to get around this problem.

I did following change and did not get any compilation error. Is this method
correct? (I will anyway test this)

HexDigit = UNum % 16;
if (HexDigit <= 9) {
WStr[Size] = L’0’;
while (HexDigit > 0) {
WStr[Size] += 1;
HexDigit–;
}
} else {
WStr[Size] = L’a’;
while ((HexDigit - 10) > 0) {
WStr[Size] += 1;
HexDigit–;
}
}

On Sun, Aug 28, 2011 at 1:35 AM, Don Burn wrote:

> You could write your own conversion function, for this one. Or can you
> just put the data in the binary data for the event log entry?
>
>
>
> Don Burn
> Windows Filesystem and Driver Consulting
> Website: http://www.windrvr.com
> Blog: http://msmvps.com/blogs/**WinDrvr http:
>
>
>
> “Sunil Patil” wrote in message news:xxxxx@ntdev:
>
> This may be a dumb question. My requirement is I need to print ULONG or
>> ULONGLONG number in event log (at dispatch level), for which I use WCHAR
>> array of size 20, copy the number ULONG/ULONGLONG in this buffer and pass
>> it
>> as input to the logging function.
>>
>> Given that I cannot use WCHAR, is there any simple thing that I can do
>> here
>> like:
>> - instead of WCHAR use CHAR (not sure if possible)
>>
>> Else in the worst case I will have to drop the event log messages.
>>
>> Thanks,
>> Sunil
>>
>> On Sun, Aug 28, 2011 at 12:24 AM, Skywing **
>> wrote:
>>
>> > No, the required data structures are pageable. You could do a
>> blind/dumb
>> > expansion of the code points to 16 bits if this is just for debugging
>> > purposes, e.g. debug prints.
>> >
>> > Best not to do that for production code though as non-ascii text would
>> be
>> > trashed.
>> >
>> > - S (MSFT)
>> > ------------------------------
>> > From: Sunil Patil
>> > Sent: Saturday, August 27, 2011 11:22
>> > To: Windows System Software Devs Interest List
>> > Subject: Re: [ntdev] Quick Basic question
>> >
>> > Is there any equivalent function to convert to wide char dispatch level?
>> >
>> > Thanks,
>> > Sunil
>> >
>> >
>> > On Sat, Aug 27, 2011 at 11:44 PM, Sunil Patil
>> wrote:
>> >
>> >> Yes they are all non-paged pool data. But I am converting some of them
>> to
>> >> wide char using function RtlStringCbPrintfExW while holding spin lock.
>> I
>> >> think this is not allowed.
>> >>
>> >>
>> >> On Sat, Aug 27, 2011 at 11:38 PM, Don Burn wrote:
>> >>
>> >>> Are you doing an IoAllocateErrorLogEntry on the same path? Do you
>> have
>> >>> strings or data that you are copying into the packet? If so are they
>> all
>> >>> non-paged data?
>> >>>
>> >>>
>> >>> Don Burn
>> >>> Windows Filesystem and Driver Consulting
>> >>> Website: http://www.windrvr.com
>> >>> Blog: http://msmvps.com/blogs/ WinDrvrhttp:
>> http:>
>>
>> >>>
>> >>>
>> >>>
>> >>>
>> >>>
>> >>> “Sunil Patil” wrote in message news:xxxxx@ntdev:
>> >>>
>> >>>
>> >>> I checked MSDN it seems “IoWriteErrorLogEntry” can be called at
>> dispatch
>> >>>> level. But I am getting a bsod while trying to log a message to event
>> >>>> log
>> >>>> with error IRQL_NOT_LESS_OR_EQUAL. I am holding a spin lock while
>> >>>> calling
>> >>>> IoWriteErrorLogEntry.
>> >>>>
>> >>>>
>> >>>> On Sat, Aug 27, 2011 at 11:05 PM, Sunil Patil
>> >>>> wrote:
>> >>>>
>> >>>> > Hi,
>> >>>> >
>> >>>> > Can we log a message in event log while holding a spin-lock?
>> >>>> >
>> >>>> > Thanks,
>> >>>> > Sunil
>> >>>> >
>> >>>>
>> >>>
>> >>>
>> >>> —
>> >>> NTDEV is sponsored by OSR
>> >>>
>> >>> For our schedule of WDF, WDM, debugging and other seminars visit:
>> >>> http://www.osr.com/seminars
>> >>>
>> >>> To unsubscribe, visit the List Server section of OSR Online at
>> >>> http://www.osronline.com/page.
cfm?name=ListServerhttp:
>> http:
>> >
>>
>> >>>
>> >>
>> >>
>> > — NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging
>> and
>> > other seminars visit: http://www.osr.com/seminars To unsubscribe, visit
>> > the List Server section of OSR Online at
>> > http://www.osronline.com/page. cfm?name=ListServerhttp:
>> >
>> > —
>> > NTDEV is sponsored by OSR
>> >
>> > For our schedule of WDF, WDM, debugging and other seminars visit:
>> > http://www.osr.com/seminars
>> >
>> > To unsubscribe, visit the List Server section of OSR Online at
>> > http://www.osronline.com/page.
cfm?name=ListServerhttp:
>> >
>>
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.**cfm?name=ListServerhttp:
></http:></http:></http:></http:></http:></http:></http:></http:>

make sure you cast hexdigit to a wchar eg (WCHAR)HexDigit

If i was writing the code I’d just use an array of characters like [L’0’, L’1’, … L’e’, L’f’] and index into that.

Sent from my iPhone

On 28/08/2011, at 17:04, “Sunil Patil” wrote:

> Hi Don,
>
> I am writing my own conversion function for this. I have code like following:
>
> HexDigit = UNum % 16;
> if (HexDigit <= 9) {
> WStr[Size] = L’0’ + HexDigit; // Step 1
> } else {
> WStr[Size] = L’a’ + (HexDigit - 10); // Step 2
> }
>
> I am getting compilation error at step 1 and 2. I checked some sites which say that we must use “btowc” for converting char int to wchar wint. Is there any kernel equivalent function for this or a way to get around this problem.
>
> I did following change and did not get any compilation error. Is this method correct? (I will anyway test this)
>
> HexDigit = UNum % 16;
> if (HexDigit <= 9) {
> WStr[Size] = L’0’;
> while (HexDigit > 0) {
> WStr[Size] += 1;
> HexDigit–;
> }
> } else {
> WStr[Size] = L’a’;
> while ((HexDigit - 10) > 0) {
> WStr[Size] += 1;
> HexDigit–;
> }
> }
>
>
>
>
> On Sun, Aug 28, 2011 at 1:35 AM, Don Burn wrote:
> You could write your own conversion function, for this one. Or can you just put the data in the binary data for the event log entry?
>
>
>
> Don Burn
> Windows Filesystem and Driver Consulting
> Website: http://www.windrvr.com
> Blog: http://msmvps.com/blogs/WinDrvr
>
>
>
> “Sunil Patil” wrote in message news:xxxxx@ntdev:
>
> This may be a dumb question. My requirement is I need to print ULONG or
> ULONGLONG number in event log (at dispatch level), for which I use WCHAR
> array of size 20, copy the number ULONG/ULONGLONG in this buffer and pass it
> as input to the logging function.
>
> Given that I cannot use WCHAR, is there any simple thing that I can do here
> like:
> - instead of WCHAR use CHAR (not sure if possible)
>
> Else in the worst case I will have to drop the event log messages.
>
> Thanks,
> Sunil
>
> On Sun, Aug 28, 2011 at 12:24 AM, Skywing wrote:
>
> > No, the required data structures are pageable. You could do a blind/dumb
> > expansion of the code points to 16 bits if this is just for debugging
> > purposes, e.g. debug prints.
> >
> > Best not to do that for production code though as non-ascii text would be
> > trashed.
> >
> > - S (MSFT)
> > ------------------------------
> > From: Sunil Patil
> > Sent: Saturday, August 27, 2011 11:22
> > To: Windows System Software Devs Interest List
> > Subject: Re: [ntdev] Quick Basic question
> >
> > Is there any equivalent function to convert to wide char dispatch level?
> >
> > Thanks,
> > Sunil
> >
> >
> > On Sat, Aug 27, 2011 at 11:44 PM, Sunil Patil wrote:
> >
> >> Yes they are all non-paged pool data. But I am converting some of them to
> >> wide char using function RtlStringCbPrintfExW while holding spin lock. I
> >> think this is not allowed.
> >>
> >>
> >> On Sat, Aug 27, 2011 at 11:38 PM, Don Burn wrote:
> >>
> >>> Are you doing an IoAllocateErrorLogEntry on the same path? Do you have
> >>> strings or data that you are copying into the packet? If so are they all
> >>> non-paged data?
> >>>
> >>>
> >>> Don Burn
> >>> Windows Filesystem and Driver Consulting
> >>> Website: http://www.windrvr.com
> >>> Blog: http://msmvps.com/blogs/ WinDrvrhttp:
>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>> “Sunil Patil” wrote in message news:xxxxx@ntdev:
> >>>
> >>>
> >>> I checked MSDN it seems “IoWriteErrorLogEntry” can be called at dispatch
> >>>> level. But I am getting a bsod while trying to log a message to event
> >>>> log
> >>>> with error IRQL_NOT_LESS_OR_EQUAL. I am holding a spin lock while
> >>>> calling
> >>>> IoWriteErrorLogEntry.
> >>>>
> >>>>
> >>>> On Sat, Aug 27, 2011 at 11:05 PM, Sunil Patil
> >>>> wrote:
> >>>>
> >>>> > Hi,
> >>>> >
> >>>> > Can we log a message in event log while holding a spin-lock?
> >>>> >
> >>>> > Thanks,
> >>>> > Sunil
> >>>> >
> >>>>
> >>>
> >>>
> >>> —
> >>> NTDEV is sponsored by OSR
> >>>
> >>> For our schedule of WDF, WDM, debugging and other seminars visit:
> >>> http://www.osr.com/seminars
> >>>
> >>> To unsubscribe, visit the List Server section of OSR Online at
> >>> http://www.osronline.com/page.
cfm?name=ListServerhttp:
>
> >>>
> >>
> >>
> > — NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and
> > other seminars visit: http://www.osr.com/seminars To unsubscribe, visit
> > the List Server section of OSR Online at
> > http://www.osronline.com/page.cfm?name=ListServer
> >
> > —
> > NTDEV is sponsored by OSR
> >
> > For our schedule of WDF, WDM, debugging and other seminars visit:
> > http://www.osr.com/seminars
> >
> > To unsubscribe, visit the List Server section of OSR Online at
> > http://www.osronline.com/page.cfm?name=ListServer
> >
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
>
> — NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</http:></http:>

Sunil Patil wrote:

This may be a dumb question. My requirement is I need to print ULONG
or ULONGLONG number in event log (at dispatch level), for which I use
WCHAR array of size 20, copy the number ULONG/ULONGLONG in this buffer
and pass it as input to the logging function.

Given that I cannot use WCHAR, is there any simple thing that I can do
here like:

  • instead of WCHAR use CHAR (not sure if possible)

Certainly. If you are simply printing hex digits, then the conversion
from char to wchar_t is trivial – you don’t need the translation tables.

char ascii[21] = “0x1234 0x5678 0x9abc”;
wchar_t wide[21];

for( i = 0; ascii[i]; i++ )
wide[i] = ascii[i];
wide[i] = 0;


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

I would never ever use non-WCHAR strings in the kernel mode code at all to begin with.

Add a little “L” to your string constants and throw away the conversion call, which cannot be called under a lock.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com