📄 roxy_inj.cpp
字号:
// roxy_inj.cpp : Defines the entry point for the DLL application.
//
// offsets version: B.2916438
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <stdio.h> // for sprintf
typedef int (WINAPI *ConnectFunction)(SOCKET S, const struct sockaddr *name, int namelen);
static ConnectFunction oldConnect;
static DWORD TrueOnWalk;
static DWORD TrueWndProc;
HCURSOR hCur;
typedef struct transfdata
{
void * walkflag_ptr;
}transfdata;
transfdata data;
volatile int walkflag;
HWND hROxyWnd = 0;
int wnd_proc_once =1;
/*
typedef LRESULT (CALLBACK * winproc_t)(HWND hWnd, UINT msg, WPARAM wparam, LPARAM lparam);
volatile winproc_t old_window_proc;
/**/
LRESULT CALLBACK hook_window_proc(HWND hWnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
if(wnd_proc_once)
{
wnd_proc_once = 0;
SetTimer(hWnd, 1, 10, NULL);
SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_NORMAL);
}
if(hROxyWnd)
{
switch(msg)
{
case WM_KEYDOWN:
case WM_KEYUP:
case WM_CHAR:
case WM_SYSKEYDOWN:
case WM_SYSKEYUP:
PostMessage(hROxyWnd, WM_USER+msg, wparam, lparam);
break;
/**/
case WM_TIMER:
Sleep(10);
break;
/**/
}
//return DefWindowProc(hWnd, msg, wparam, lparam); // for blocking
}
if(msg == WM_USER+111)
{
hROxyWnd = (HWND)wparam;
return 0;
}
return CallWindowProc((WNDPROC)TrueWndProc, hWnd, msg, wparam, lparam);
}
int doSend(SOCKET S, const char * data, int len)
{
int offset = 0;
while(len)
{
int res = send(S, data+offset, len, 0);
if( (res == INVALID_SOCKET)
&& (WSAGetLastError()!=WSAEWOULDBLOCK)
)
{
return 0;
}
offset += res;
len -= res;
}
return 1;
}
int WINAPI MyConnect(SOCKET S, const struct sockaddr *name, int namelen)
{
struct hostent * host;
struct sockaddr_in sin;
host = gethostbyname("localhost");
if(!host)
{
MessageBox(NULL, "`localhost` unresolved!", "", MB_OK);
return INVALID_SOCKET;
}
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = ((struct in_addr *)(host->h_addr))->s_addr;
sin.sin_port = htons( 1616 ); // ROxy port
// call trampoline;
int res = oldConnect(S, (LPSOCKADDR)&sin, sizeof(sin) );
int old_WSA_Error = WSAGetLastError();
/*
char s[100];
sprintf(s, "%d %d", ((struct sockaddr_in *) name)->sin_port, WSAGetLastError());
MessageBox(NULL, s, s, MB_OK );
/**/
if( res==0 // sucessfull connect
|| WSAGetLastError()==WSAEWOULDBLOCK
)
{
// Sending pre-packet;
//亦
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -