Folks,
All your points are noted. Thanks.
The code blue screened even without the spin lock. The spin lock was
added to prevent possible buffer sharing issues because gBuffer is
global.
The try except was also added during debugging. I need to remove it.
Please tell me if how best to get the process name from the pid in the
kernel (one that does not involve undocumented calls and pageable code).
I did some googling and did not come up with anything.
Thanks,
-Charu.
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Wednesday, December 07, 2005 11:14 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] ZwQuerySystemInformation crash
Charu Venkatraman wrote:
I have a function that determines processname from the process id
inside a tdi driver. The code seems to get the process name correctly
in most cases, but the problem is that after this function is called
‘n’ times, my system blue screens with the 7e error. The blue screen
appears to happen at random times, and does not depend on running any
particular process. The entire code snippet is given below. Can
someone give me pointers as to what could be going wrong?
#define MIN(a,b) ((a) > (b) ? (b) : (a))
/* Function to determine current process name in the kernel */
int MyTdi_GetCurrentProcessName(char *ProcessName)
{
ULONG cbBuffer = 0x10000; // declare initial size of buffer - 64
NTSTATUS Status;
PSYSTEM_PROCESS_INFORMATION pInfo;
KIRQL irql;
int ret = FALSE;
__try {
ULONG pid = (ULONG)PsGetCurrentProcessId();
DbgPrint(“MyTdi_GetCurrentProcessName\r\n”);
KeAcquireSpinLock(&ns_getprocname_lock, &irql);
THAT is your key problem. Once you acquire the spinlock, you run at an
elevated IRQL, and several of the interfaces you call (such as
ZwQuerySystemInformation and wcstombs) cannot be called at an elevated
IRQL. That will result in an eventual, although unpredictable, blue
screen.
I don’t understand why you acquire the spin lock at all. It doesn’t seem
to be necessary. And why do you convert back to ANSI? Why can’t you just
keep the Unicode name around?
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com