Question on RtlStringCbVPrintfA

Hello,

The documentation of the function says that it can only be called at PASSIVE_LEVEL.

I understand that, calling it at >= DISPATCH_LEVEL may result in a BSOD, if anything accessed during the call directly (RtlStringCbVPrintfA code and it’s internal routines and/or parameters) OR indirectly (NLS tables) is paged out.

However, I am wondering, it is safe to call the API at APC_LEVEL?

If not, is there any alternate function that I can use? Basically I want to write a log function that has printf style syntax which kind of sprintfs into a buffer and send it another internal routine that only takes “char *buffer” as input. Ideally, I would like this to work at <= DISPATCH_LEVEL OR at least <= APC_LEVEL. I will ensure that I will not pass it any data that is paged out.

Thoughts?

Thanks.
-Prasad

I’m assuming that in addition to APC_LEVEL you also are interested in
PASSIVE_LEVEL within a guarded region, which I’m going to lump in with
APC_LEVEL for the remainder of the conversation.

The answer, of course, is it depends. In general, there’s no issue for the
O/S in dealing with page faults at APC_LEVEL. However, as you noted, these
APIs may need to generate paging *file* I/O. Thus, if you’re at APC_LEVEL
due to being in the paging file I/O path, then you can’t call these APIs.

-scott
OSR

wrote in message news:xxxxx@ntfsd…

Hello,

The documentation of the function says that it can only be called at
PASSIVE_LEVEL.

I understand that, calling it at >= DISPATCH_LEVEL may result in a BSOD, if
anything accessed during the call directly (RtlStringCbVPrintfA code and
it’s internal routines and/or parameters) OR indirectly (NLS tables) is
paged out.

However, I am wondering, it is safe to call the API at APC_LEVEL?

If not, is there any alternate function that I can use? Basically I want to
write a log function that has printf style syntax which kind of sprintfs
into a buffer and send it another internal routine that only takes “char
*buffer” as input. Ideally, I would like this to work at <= DISPATCH_LEVEL
OR at least <= APC_LEVEL. I will ensure that I will not pass it any data
that is paged out.

Thoughts?

Thanks.
-Prasad

Thanks for the response Scott.

Hence, in a mini-filter, it should be safe, unless mini-filter is servicing a paging I/O request and calling the RtlStringCbVPrintfA function generates a page fault (directly or indirectly).

BTW, before posting the question, I was looking at the DbgPrint(Ex) documentation, since it must be doing similar to what I am trying to do. It has similar restrictions i.e. if one is using unicode format codes (which indirectly means there is a chance of accessing paged data), it can be called only at PASSIVE_LEVEL, otherwise, it can be called at <= DISPATCH_LEVEL

Thanks.
-Prasad