⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 srhword.c

📁 屏幕取词源码.zip
💻 C
📖 第 1 页 / 共 3 页
字号:
        HookWinApi(&g_ExtTextOutHook, ONLYHOOK);
#ifdef _DEBUG
        DbgPrintf("NhWSrh.DLL     BLExtTextOut End");
#endif
        return (TRUE);
}         

BOOL WINAPI _export BLBitBlt(HDC hdcDest,
                             int nXDest,
                             int nYDest,
                             int nWidth,
                             int nHeight,
                             HDC hdcSrc,
                             int nXSrc,
                             int nYSrc,
                             DWORD dwRop)
{
        int x, y;

#ifdef _DEBUG
        DbgPrintf("NhWSrh.DLL     BLBitBlt Begin");
#endif

        // restore the old textout.
        RestoreWinApi(&g_BitBltHook);
    
#ifdef _DEBUG
        DbgPrintf("NhWSrh.DLL     BitBlt: hdcDest: %d, hdcSrc: %d, nXDest: %d, nYDest, %d, nWidth: %d, nHeight: %d",
                          hdcDest,
                          hdcSrc,
                          nXDest,
                          nYDest,
                          nWidth,
                          nHeight);
#endif
        
        if (nWidth > 5)
        {
                g_dwDCOrg = GetDCOrg(hdcDest);
                x = LOWORD(g_dwDCOrg);
                y = HIWORD(g_dwDCOrg);
                x += nXDest;
                y += nYDest;
                g_dwDCOrg = MAKELONG(x, y);
                
                CheckMemDCWordBuffer(hdcDest, hdcSrc);
        }
		else
		{
#ifdef _DICTING_
			if (CheckDCWndClassName(hdcDest))
			{
#ifdef _DEBUG
				DbgPrintf("NhWSrh.DLL          In IE4");
#endif
                g_dwDCOrg = GetDCOrg(hdcDest);
                x = LOWORD(g_dwDCOrg);
                y = HIWORD(g_dwDCOrg);
                x += nXDest;
                y += nYDest;
                g_dwDCOrg = MAKELONG(x, y);
                
                CheckMemDCWordBuffer(hdcDest, hdcSrc);
			}
#endif
		}
        
        // call old textout.
        BitBlt(hdcDest, 
                   nXDest, 
                   nYDest, 
                   nWidth, 
                   nHeight, 
                   hdcSrc, 
                   nXSrc,
                   nYSrc,
                   dwRop);

        HookWinApi(&g_BitBltHook, ONLYHOOK);

#ifdef _DEBUG
        DbgPrintf("NhWSrh.DLL     BLBitBlt End");
#endif
        return (TRUE);
}         

void FAR PASCAL _export Nh16_AddToTotalWord(LPSTR  szBuff,
					                        int    cbLen,
					                        int    nBegin,
					                        int    nEnd,
                    					    int    nCharType,
                         					LPRECT lpStringRect,
                         					BOOL   bInCurWord,
                         					int    nCurCaretPlace)
{
#ifdef _DEBUG
	DbgPrintf("NhW16.dll       ExtTextOutW: %s", szBuff);
	DbgPrintf("NhW16.dll       ExtTextOutW: Rect l: %d, r: %d, t: %d, b: %d",
			  lpStringRect->left,
			  lpStringRect->right,
			  lpStringRect->top,
			  lpStringRect->bottom);
	DbgPrintf("NhW16.dll       ExtTextOutW: Mouse point : x: %d, y: %d",
				g_CurMousePos.x,
				g_CurMousePos.y);
#endif
	g_nCurCaretPlace = nCurCaretPlace;
	AddToTotalWord(szBuff, cbLen, nBegin, nEnd, nCharType, *lpStringRect, bInCurWord);
}

int FAR PASCAL _export Nh16_GetTempLen()
{
#ifdef _DEBUG
	DbgPrintf("NhW16.dll       ExtTextOutW: Nh16_GetTempLen: %s", szMemDCWordBuff);
#endif
	return strlen(szMemDCWordBuff);
}

BOOL FAR PASCAL _export Nh16_AddToTempBuff(LPSTR  szBuff,
					                       int    cbLen)
{
	int  nLen;
	
#ifdef _DEBUG
	DbgPrintf("NhW16.dll       ExtTextOutW: Nh16_AddToTempBuff: Before Add: %s", szMemDCWordBuff);
#endif
	if (cbLen >= (int)(BUFFERLENGTH - strlen(szMemDCWordBuff) - 2))
	{
		// buffer too small.
		return FALSE;
	}

	// Write string to buffer.
	nLen = strlen(szMemDCWordBuff);
	strncpy(szMemDCWordBuff + nLen, szBuff, cbLen);
	szMemDCWordBuff[nLen + cbLen    ] = ' ';
	szMemDCWordBuff[nLen + cbLen + 1] = 0x00;
	
#ifdef _DEBUG
	DbgPrintf("NhW16.dll       ExtTextOutW: Nh16_AddToTempBuff: after Add: %s", szMemDCWordBuff);
#endif
	return TRUE;
}					                       

BOOL FAR PASCAL _export Nh16_AddToWordStruct(int nBegin,
											 int nEnd,
											 HDC hMemDC, 
											 int CharType, 
											 LPRECT lpStringRect)
{
#ifdef _DEBUG
	int i;
	DbgPrintf("NhW16.dll       ExtTextOutW: Nh16_AddToWordStruct begin.");
#endif
//////////////////////////////////////////////////////////////
// Modified by Yan/gang 1998.02.20
// Reason: 
//         It cause the system destroy when the user run "WBLASTER"
//         The reason is the the array is overflow.
//         The WordBuffer array size is MEMDC_MAXNUM.
//         But it's point (nWordNum) is large than MEMDC_MAXNUM,
//         also, nWordNum is small than MAXNUM.
//	if (nWordNum >= MAXNUM)
	if (nWordNum >= MEMDC_MAXNUM)
		return FALSE;
// Modify end.
//////////////////////////////////////////////////////////////

	WordBuffer[nWordNum].nBegin = nBegin;
	WordBuffer[nWordNum].nEnd   = nEnd;
	WordBuffer[nWordNum].hMemDC = hMemDC;
	WordBuffer[nWordNum].CharType = CharType;
	WordBuffer[nWordNum].wordRect.left   = lpStringRect->left;
	WordBuffer[nWordNum].wordRect.right  = lpStringRect->right;
	WordBuffer[nWordNum].wordRect.top    = lpStringRect->top;
	WordBuffer[nWordNum].wordRect.bottom = lpStringRect->bottom;
		
	nWordNum++;
	
#ifdef _DEBUG
	for (i = 0; i < nWordNum; i++)
	{
		DbgPrintf("NhW16.dll       nBegin: %d, nEnd: %d, l: %d, r: %d, t: %d, b: %d",
				  WordBuffer[i].nBegin,
				  WordBuffer[i].nEnd,
				  WordBuffer[i].wordRect.left,
				  WordBuffer[i].wordRect.right,
				  WordBuffer[i].wordRect.top,
				  WordBuffer[i].wordRect.bottom);
	}
	DbgPrintf("NhW16.dll       ExtTextOutW: Nh16_AddToWordStruct end.");
#endif
	return TRUE;
}											 

BOOL FAR PASCAL _export Nh16_AddToCharStruct(int nBeignPlace, int nLeft, int nRight)
{
#ifdef _DEBUG
	DbgPrintf("NhW16.dll       ExtTextOutW: Nh16_AddToCharStruct, nBeginPlace: %d, nleft: %d, nRight: %d",
			  nBeignPlace,
			  nLeft,
			  nRight);
#endif
	pnMemDCCharLeft[nBeignPlace]  = nLeft;
	pnMemDCCharRight[nBeignPlace] = nRight;
	
	return TRUE;
}
					                       
//==================================
// PHYS - Matt Pietrek 1995
// FILE: PHYS16.C
//==================================


static char MS_DOS_STR[] = "MS-DOS";

//
// Return a far pointer to the LDT
//
unsigned short GetLDTAlias(void)
{
    unsigned short  LDT_alias;
    unsigned short  (far * dpmiproc)(void);

    //
    // Use INT 2Fh, fn. 168A to get the "DPMI extensions
    // entry point" function pointer
    //
    _asm     mov     si, offset MS_DOS_STR   // DS:SI = "MS-DOS"
    _asm     mov     ax, 168Ah
    _asm     int     2Fh
    _asm     cmp     al, 8Ah
    _asm     je      extensions_not_found

    //
    // The entry point is returned in ES:DI.  Save it
    //
    _asm     mov     word ptr [dpmiproc], di
    _asm     mov     word ptr [dpmiproc+2], es

    //
    // Call the extensions with AX == 0x100.  The LDT alias
    // selector is return in AX.  Carry flag is set on failure.
    //
    _asm     mov     ax, 100h
    LDT_alias = dpmiproc();
    _asm     jc      extensions_not_found;

    return  LDT_alias;

extensions_not_found:   // We get here if something failed
    return  0;
}

WORD FAR PASCAL __loadds GetRing0Callgate( DWORD func_address,
											unsigned cParams )
{
    CALLGATE_DESCRIPTOR far *callgate_desc;
    CODE_SEG_DESCRIPTOR far *ring0_desc;
    unsigned short ldt_alias;
    unsigned short ring_0_alias;
    unsigned short callgate_selector;

    if ( (ldt_alias = GetLDTAlias()) == 0 )
        return 0;

    //
    // Grab a selector from Windows to use as the CS at ring 0
    //
    if ( !(ring_0_alias = AllocSelector(0)) )
        return 0;

    //
	// Set up the fields in the descriptor to be a ring 0, flat model seg
    //
    ring0_desc = MAKELP( ldt_alias, ring_0_alias & 0xFFF8 );
	ring0_desc->limit_0_15 = 0xFFFF;
	ring0_desc->base_0_15 = 0;
	ring0_desc->base_16_23 = 0;
	ring0_desc->readable = 1;
	ring0_desc->conforming = 0;
	ring0_desc->code_data = 1;
	ring0_desc->app_system = 1;
    ring0_desc->dpl = 0;
    ring0_desc->present = 1;
	ring0_desc->limit_16_19 = 0xF;
	ring0_desc->always_0 = 0;
	ring0_desc->seg_16_32 = 1;
	ring0_desc->granularity = 1;
	ring0_desc->base_24_31 = 0;
	
    //
    // Allocate the selector that'll be used for the call gate
    //
    if ( (callgate_selector= AllocSelector(0)) == 0 )
    {
        FreeSelector( ring_0_alias );
        return 0;
    }

    //
    // Create a pointer to the call gate descriptor
    //
    callgate_desc = MAKELP( ldt_alias, callgate_selector & 0xFFF8 );

    //
    // Fill in the fields of the call gate descriptor with the
    // appropriate values for a 16 bit callgate.
    //
    callgate_desc->offset_0_15 = LOWORD( func_address );
    callgate_desc->selector = ring_0_alias;
    callgate_desc->param_count = cParams;
    callgate_desc->some_bits = 0;
    callgate_desc->type = 0xC;          // 386 call gate
    callgate_desc->app_system = 0;      // A system descriptor
    callgate_desc->dpl = 3;             // Ring 3 code can call
    callgate_desc->present = 1;
    callgate_desc->offset_16_31 = HIWORD(func_address);

    return callgate_selector;
}

BOOL FAR PASCAL __loadds FreeRing0Callgate( WORD callgate )
{
    CALLGATE_DESCRIPTOR far *callgate_desc;
    unsigned short ldt_alias;

    if ( (ldt_alias = GetLDTAlias()) == 0 )
        return FALSE;

    //
    // Create a pointer to the call gate descriptor
    //
    callgate_desc = MAKELP( ldt_alias, callgate & 0xFFF8 );

    //
    // First, free the ring 0 alias selector stored in the LDT
    // call gate descriptor, then free the call gate selector.
    //
    FreeSelector( callgate_desc->selector );
    FreeSelector( callgate );
}

//Added by XGL, Dec 8th, 1998
BOOL IsParentOrSelf(HWND hParent, HWND hChild)
{
	HWND hTemp = hChild;
	HWND hDesktop ;
	
	if (hParent == NULL || hChild == NULL)
	{
		return FALSE ;
	}

	hDesktop = GetDesktopWindow() ;
	while (hTemp != NULL && hTemp != hDesktop)
	{
		if (hTemp == hParent)
		{
			return TRUE ;
		}

		hTemp = GetParent(hTemp) ;
	}

	return FALSE ;
}
//Adding ends.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -