ãWin32 APIã«ã¯OutputDebugString()ã¨ããé¢æ°ãæä¾ããã¦ãã¾ããããã¯ãVC6.0ã§ã¯ããããã°ãã¿ãã«ããã°ã©ã ããä»»æã®æååãåºåããããã¨ãã§ãã¾ããããããCã©ã³ã¿ã¤ã ã§è¨ãã¨ããã®printf()ã®ããã«ãæ¸å¼å¶å¾¡ã¯ããã¾ãããåºæ¬çã«ã¯ã¿ããªãã¯ããå¶å¾¡æåã追å ããé¢æ°ã使ã£ã¦ããããã§ã(ç§ãèªä½ã§ä½¿ã£ã¦ãã¾ã)ã
ããã®æååã¯ãããã¬ã§ããã¨ããªãã®ã§ããããï¼ãããªãã¨ã¯ããã¾ãããPlathome SDKã«dbmonã¨ãããµã³ãã«ããããçµæ§ç°¡åã«ã¨ã£ã¦ã¾ããã¨ãã»ã³ã¹ã ãæãåºãã¦ã¿ã¾ããããã ãã ã¨åãªãã³ã³ã½ã¼ã«ã¸ã®åºåã«ãªãã¾ãããé©å®ãã¡ã¤ã«ã¸ã®æ¸ãè¾¼ã¿ããã¦ã¿ãã¨ã(ç§ã¯ãã)ããããã¯ã¼ã¯ã¸ãªãã¤ã¬ã¯ããã¦ããã£ã¡ã§ã§ã£ãããããã¡ç¨æãã¦ã貯ãããã¨ãã¡ã¤ã«ã¸æ¸ãè¾¼ãã¨ãããããå¿ç¨ãåºããã¨æãã¾ããç¹ã«ã²ã¼ã ãªããã§ã§ããã ããã¼ã«ã«PCã«è² æ ããããããªãå ´åã¨ãããã§ããã
ãå®ã¯ãä¼åããã®æ¥è¨ Device\PhysicalMemory ãªãã¸ã§ã¯ããèªãã§ãããWindows Server 2003 SP1ã§dbmon(ç§ã¯dblogã¨æ¹åï¼æ©è½æ¹è¯ãã¦ä½¿ã£ã¦ã¾ãã)åããªããªãããªï¼ã¨æã£ã¦ã½ã¼ã¹ãè¦ç´ããã®ã§ãã(^^;(ããã大ä¸å¤«ã ã¨ã¯æã£ã¦ã¾ãããã©)ã
HANDLE hAckEvent, hReadyEvent, hSharedFile;
LPVOID pSharedMem;
LPSTR pString;
DWORD ret, dwBuf;
LPDWORD pThisPid;
TCHAR tszTempBuffer[1024];
SECURITY_ATTRIBUTES sa;
SECURITY_DESCRIPTOR sd;
// ã»ãã¥ãªãã£ã®åæå
InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(&sd, TRUE, (PACL)NULL, FALSE);
// OutputDebugStringã§æ¸ãè¾¼ãã ãã¼ã¨ããã¤ãã³ããåå¾ããããã«ã¤ãã³ãä½æã
hAckEvent = CreateEvent(&sa, FALSE, FALSE, "DBWIN_BUFFER_READY");
hReadyEvent = CreateEvent(&sa, FALSE, FALSE, "DBWIN_DATA_READY");
// OutputDebugString()ã§æ¸ãè¾¼ã¾ãããããã¡ãå ±æã¡ã¢ãªã§éã
hSharedFile = CreateFileMapping((HANDLE)-1, &sa, PAGE_READWRITE, 0, 4096, "DBWIN_BUFFER");
pSharedMem = MapViewOfFile(hSharedFile, FILE_MAP_READ, 0, 0, 512);
pString = (LPSTR)pSharedMem + sizeof(DWORD);
pThisPid = (LPDWORD)pSharedMem;
SetEvent(hAckEvent); // æºåå®äºã¾ã§å¾ ã¤
for (;;) {
ret = WaitForSingleObject(hReadyEvent, INFINITE);
if (ret == WAIT_OBJECT_0) {
lstrcpyn(tszTempBuffer, pString);
printf("%s", pString);
SetEvent(hAckEvent);
}
}