Createing A Loader!

03/27/2012 18:05 Mr_PoP#1
so am working on MFC application VC++11 and am doing the following

Code:
::OnBnClickedButton1()
{
    STARTUPINFO si;
    PROCESS_INFORMATION pi;
    HMODULE hDll;
    FARPROC cbtProcAddr;
    memset(&si, 0, sizeof(si));
    memset(&pi, 0, sizeof(pi));
    si.cb = sizeof(si);
    char * procName = "D:\\Conquer Online 2.0\\Conquer.exe";
    char * procArg  = " blacknull";

    if(CreateProcess(procName,procArg,0,0,0,CREATE_DEFAULT_ERROR_MODE,0,"D:\\Conquer Online 2.0",&si,&pi)){
		hDll = GetModuleHandle("WS2_32.dll");
		cbtProcAddr = GetProcAddress(hDll, "inet_addr");

		sockaddr_in localaddr;
		localaddr.sin_addr.s_addr = inet_addr("5.230.189.19");
		localaddr.sin_port = htons(9959);
		localaddr.sin_family = AF_INET;

		WaitForInputIdle(pi.hProcess,INFINITE);
		WriteProcessMemory(pi.hProcess,cbtProcAddr,(sockaddr*)&localaddr,sizeof(localaddr),0);
	}
    
}
the game launches and when am trying to logging in the client crashes! any clue why?
03/27/2012 21:05 ×Holo#2
This goes to CO2 Programming :]

OP:Glad that you got the crypto, keep it up~!
03/27/2012 21:53 KraHen#3
MFC? Really?
03/28/2012 01:19 Mr_PoP#4
Quote:
Originally Posted by ×Holo View Post
This goes to CO2 Programming :]

OP:Glad that you got the crypto, keep it up~!
ah thnx :)

Quote:
Originally Posted by KraHen View Post
MFC? Really?
yeah what's wrong!?
03/29/2012 00:29 CptSky#5
Quote:
Originally Posted by Mr_PoP View Post
yeah what's wrong!?
Microsoft Foundation Class Library is a C++ wrapper of the Win32 C API. You can't make a MFC program... You're making a program that uses MFC.
03/29/2012 01:15 _DreadNought_#6
Try hooking the connect function instead, that's what my C++ and C# loaders do.

so
Code:
cbtProcAddr = GetProcAddress(hDll, "inet_addr");
to
Code:
cbtProcAddr = GetProcAddress(hDll, "connect");
03/29/2012 13:19 Mr_PoP#7
Quote:
Originally Posted by CptSky View Post
Microsoft Foundation Class Library is a C++ wrapper of the Win32 C API. You can't make a MFC program... You're making a program that uses MFC.
dude come on is not that obvious? should I say " am making a program that uses MFC!?" lol , what I said is that am creating an MFC application in VC++ hence it's uses MFC lol

Quote:
Originally Posted by _DreadNought_ View Post
Try hooking the connect function instead, that's what my C++ and C# loaders do.

so
Code:
cbtProcAddr = GetProcAddress(hDll, "inet_addr");
to
Code:
cbtProcAddr = GetProcAddress(hDll, "connect");
will try it thnx
03/30/2012 04:20 _DreadNought_#8
Did it work?
03/30/2012 08:11 Nullable#9
It HAS to crash; you're pretty much overwriting inet_addr's bytecode with the representation of an IPv4 address, this is definitely not "hooking"/"patching".
Anyway,
Code:
MOV EAX, <IPAddress>
RETN 4
Try to build up from there. If you don't get what this is, time to research.

EDIT:
And, as previously pointed out by KraHen, MFC? Seriously?
03/30/2012 21:11 Mr_PoP#10
Quote:
Originally Posted by _DreadNought_ View Post
Did it work?
yeah hooked connect using Detours.

Quote:
Originally Posted by Nullable View Post
It HAS to crash; you're pretty much overwriting inet_addr's bytecode with the representation of an IPv4 address, this is definitely not "hooking"/"patching".
Anyway,
Code:
MOV EAX, <IPAddress>
RETN 4
Try to build up from there. If you don't get what this is, time to research.

EDIT:
And, as previously pointed out by KraHen, MFC? Seriously?
aha , I already got it working using Detours , and again MFC seriously rofl :P ("I have answered that question previously!!!")