PSID psidSystem = NULL;
PSID psidAdministrators = NULL;
PSID psidEveryone = NULL;
-
+
/* buffer for the DACL */
PVOID pDaclBuf = NULL;
/* security descriptor of the mutex */
SECURITY_DESCRIPTOR sdMutexSecurity;
-
+
/* attributes of the mutex object we'll create */
SECURITY_ATTRIBUTES saMutexAttribs =
{
0,
&psidAdministrators
);
-
+
/* failure */
if(!NT_SUCCESS(nErrCode)) __leave;
0,
&psidEveryone
);
-
+
/* failure */
if(!NT_SUCCESS(nErrCode)) __leave;
/* create the security descriptor */
nErrCode = RtlCreateSecurityDescriptor
- (
+ (
&sdMutexSecurity,
SECURITY_DESCRIPTOR_REVISION
);
#if 0
}
#endif
-
+
return hMutex;
}
{
/* synchronize with other invocations of OutputDebugString */
WaitForSingleObject(hDBMonMutex, INFINITE);
-
+
/* buffer of the system-wide debug message monitor */
hDBMonBuffer = OpenFileMappingW(SECTION_MAP_WRITE, FALSE, L"DBWIN_BUFFER");
-
+
/* couldn't open the buffer: send the string to the kernel debugger */
if(hDBMonBuffer == NULL) break;
-
+
/* map the buffer */
pDBMonBuffer = MapViewOfFile
(
0,
0
);
-
+
/* couldn't map the buffer: send the string to the kernel debugger */
if(pDBMonBuffer == NULL) break;
-
+
/* open the event signaling that the buffer can be accessed */
hDBMonBufferReady = OpenEventW(SYNCHRONIZE, FALSE, L"DBWIN_BUFFER_READY");
-
+
/* couldn't open the event: send the string to the kernel debugger */
if(hDBMonBufferReady == NULL) break;
-
+
/* open the event to be signaled when the buffer has been filled */
hDBMonDataReady =
OpenEventW(EVENT_MODIFY_STATE, FALSE, L"DBWIN_DATA_READY");
nRoundLen = PAGE_SIZE - sizeof(DWORD) - 1;
else
nRoundLen = nOutputStringLen;
-
+
/* copy the current block into the buffer */
- memcpy(pDBMonBuffer->Buffer, _OutputString, nOutputStringLen);
-
+ memcpy(pDBMonBuffer->Buffer, _OutputString, nRoundLen);
+
/* null-terminate the current block */
- pDBMonBuffer->Buffer[nOutputStringLen] = 0;
-
+ pDBMonBuffer->Buffer[nRoundLen] = 0;
+
/* signal that the data contains meaningful data and can be read */
SetEvent(hDBMonDataReady);
}
{
/* output in blocks of 512 characters */
CHAR a_cBuffer[512];
-
+
/* write a maximum of 511 bytes */
if(nOutputStringLen > (sizeof(a_cBuffer) - 1))
nRoundLen = sizeof(a_cBuffer) - 1;
else
nRoundLen = nOutputStringLen;
-
+
/* copy the current block */
memcpy(a_cBuffer, _OutputString, nRoundLen);
-
+
/* null-terminate the current block */
a_cBuffer[nRoundLen] = 0;
-
+
/* send the current block to the kernel debugger */
DbgPrint("%s", a_cBuffer);
}
{
/* output the converted string */
OutputDebugStringA(strOut.Buffer);
-
+
/* free the converted string */
RtlFreeAnsiString(&strOut);
}