资源描述:
《改建精灵dll源码 钩子》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、改建精灵dll源码钩子#include#includeHHOOKg_hKey;intm__y1,m__y2,m__y3,m__y4,m__g1,m__g2,m__g3,m__g4;LRESULT__declspec(dllexport)__stdcallKeyProc(intcode,//hookcodeWPARAMwParam,//virtual-keycodeLPARAMlParam//keystroke-messageinformation);){//MessageBeep(10
2、00);if(wParam==65){MessageBeep(500);keybd_event('B',MapVirtualKey('B',0),0,0);//键下键keybd_event('B',MapVirtualKey('B',0),KEYEVENTF_KEYUP,0);//放开键。returnTRUE;}returnCallNextHookEx(g_hKey,code,wParam,lParam);}voidSetHook(intm_g1,intm_Gkey2,intm_Gkey3,intm_Gkey4,intm_y1,
3、intm_Ykey2,intm_Ykey3,intm_Ykey4){m__y1=m_y1;g_hKey=SetWindowsHookEx(WH_KEYBOARD,KeyProc,GetModuleHandle("War3GJ_DLL"),0);}HBITMAPCScreenDlg::CopyScreenToBitmap(LPRECTlpRect){HDChScrDC,hMemDC;HBITMAPhOldBitmap,hBitmap;intnX,nY,nX2,nY2;intnWidth,nHeight;intxScrn,yScrn
4、;if(IsRectEmpty(lpRect))returnNULL;hScrDC=CreateDC("DISPLAY",NULL,NULL,NULL);hMemDC=CreateCompatibleDC(hScrDC);nX=lpRect->left;nY=lpRect->top;nX2=lpRect->right;nY2=lpRect->bottom;xScrn=GetDeviceCaps(hScrDC,HORZRES);yScrn=GetDeviceCaps(hScrDC,VERTRES);if(nX<0)nX=0;if(
5、nY<0)nY=0;if(nX2>xScrn)nX2=xScrn;if(nY2>yScrn)nY2=yScrn;nWidth=nX2-nX;nHeight=nY2-nY;hBitmap=CreateCompatibleBitmap(hScrDC,nWidth,nHeight);hOldBitmap=(HBITMAP)SelectObject(hMemDC,hBitmap);ShowWindow(SW_HIDE);BitBlt(hMemDC,0,0,nWidth,nHeight,hScrDC,nX,nY,SRCCOPY);hBit
6、map=(HBITMAP)SelectObject(hMemDC,hOldBitmap);DeleteDC(hScrDC);DeleteDC(hMemDC);ShowWindow(SW_SHOW);returnhBitmap;}BOOLSaveBitmapToFile(HBITMAPhBitmap,LPCSTRlpszFileName){HDChDC;//设备描述表intiBits;//当前显示分辨率下每个像素所占字节数WORDwBitCount;//位图中每个像素所占字节数//定义调色板大小,位图中像素字节大小,位图文件大小,
7、写入文件字节数DWORDdwPaletteSize=0,dwBmBitsSize,dwDIBSize,dwWritten;BITMAPBitmap;//位图属性结构BITMAPFILEHEADERbmfHdr;//位图文件头结构BITMAPINFOHEADERbi;//位图信息头结构LPBITMAPINFOHEADERlpbi;//指向位图信息头结构HANDLEfh,hDib,hPal;HPALETTEhOldPal=NULL;//定义文件,分配内存句柄,调色板句柄//计算位图文件每个像素所占字节数hDC=CreateDC("D
8、ISPLAY",NULL,NULL,NULL);iBits=GetDeviceCaps(hDC,BITSPIXEL)*GetDeviceCaps(hDC,PLANES);DeleteDC(hDC);if(iBits<=1)wBitCount=1;elseif(i