PRG26 - ��� �� DosMon*?
From
FAQServer@2:5020/181 to
All on Mon Jun 23 07:37:09 2025
[Q]: ��� �� DosMon*?
[A]: Serge Ivanov (2:5000/7.22)
��� �y᮪, ���p� �ᯮ�짮����� � Chump`�, �.�. �� ��� �����p� �������yp�.
��� �py��� y��p���� �y��� �������� ���� p����p � ��py��yp� �y�p�.
�� ����� ᮮ�p������ �뤥����� 128 ���� ��� �y�p�� � �� �����, ����� ��ᠫ���, �������, � ���� �뫮 ����ᠭ�, �� �y�p ������ ���� �����, 祬 p����� p����p �����p���� �����. �� �� ����������� MSC 6.0.
-------------------------------------------
#define BUFFSIZE 128
typedef struct _MONBUF{
USHORT fMon;
UCHAR bChar;
UCHAR bScan;
UCHAR fbStatus;
UCHAR bNlsShift;
USHORT fsState;
ULONG time;
USHORT fDD;
} MONBUF;
VOID main(VOID)
{
HMONITOR kbdH = 0;
PGINFOSEG pGIS; // Information segment structures
PLINFOSEG pLIS;
USHORT i,
ms; // Maximum sessions to monitor
TID tid;
PBYTE buf, pin;
USHORT_(pGIS) = USHORT_(pLIS) = 0;
DosGetInfoSeg((PSEL)&pGIS + 1, (PSEL)&pLIS + 1);
buf = MAKEP(pLIS->selEnvironment, pLIS->offCmdLine);
buf = &buf[strlen(buf)+1];
ms = atoi(buf);
if(ms == 0)
ms = pGIS->sgMax;
DosMonOpen("KBD$", &kbdH);
DosSetPrty( PRTYS_PROCESS, PRTYC_TIMECRITICAL, PRTYD_MAXIMUM, 0 );
for(i = 0; i < pGIS->sgMax; i++)
{
if(i >= ms) // if limited number of sessions
break;
// ��� �p��p���, ���y饭��� �� config.sys �������� RUN:
// ��⨢��� ���� �� �ᯮ��y���� �p� ��p���쭮� p����.
if(i == pGIS->sgCurrent)
{
ms++;
continue;
}
pin = _fmalloc(BUFFSIZE * 2); // allocate memory for input & output
// buffer
buf = _fmalloc(0x200);
USHORT_(pin[0]) = USHORT_(pin[BUFFSIZE]) = BUFFSIZE;
ULONG_(buf[0x1F4]) = (ULONG)&pin[0]; // pass pointers to buffers
ULONG_(buf[0x1F8]) = (ULONG)&pin[BUFFSIZE]; // to thread function
if(DosMonReg(kbdH, pin, &pin[BUFFSIZE], 1, i))
{
// Cleanup if fails
_ffree(buf);
_ffree(pin);
ms++;
continue;
}
DosCreateThread((PFNTHREAD)Monitor, &tid, &buf[0x1F4]);
}
DosSuspendThread(pLIS->tidCurrent);
}
VOID Monitor(PBYTE pin, PBYTE pout)
{
MONBUF mb;
USHORT cb;
while(1)
{
cb = sizeof(MONBUF);
if(DosMonRead((PBYTE)pin, IO_WAIT, (PBYTE)&mb, &cb))
continue;
// do something useful here
cb = sizeof(MONBUF);
DosMonWrite((PBYTE)pout, (PBYTE)&mb, cb);
}
}
---------------------------------------
--- INN 2.7.3
* Origin: This echo is READ-ONLY. Send %HELP to FAQSERVER at (2:5020/181)