Start up your VC++, Go to File > New Project > Win32 > Win32 Project
Give it a name "MyDLL" for this tutorial, Click Next. For Application Type
set it to DLL and Additional Options: Check "Empty Project"
Now you should See 3 folders in your solution explorer.
Right Click on "Source Files" and Add > New Item > Code > C++ File (.cpp)
give it a name "MainDLL".
inside "MainDLL.cpp" copy and paste this code in
Code:
#include <windows.h>
extern int Main(); //tells compiler that function Main is located somewhere else.
void WINAPI MainThread( )
{
//This function will run when we attach the DLL to the Game//
Main(); //located in Form1.cpp, This will load the form and display it
//We will Create our Main() function later.
}
BOOL WINAPI DllMain ( HMODULE hModule, DWORD dwReason, LPVOID lpvReserved )
{
switch ( dwReason ) {
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hModule);
if ( CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)MainThread, NULL, 0, NULL) == NULL ) {
return FALSE;
}
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
return TRUE;
}
Now that you have the code in your MainDLL time to make a form.
Right Click on "Header Files" and Add > New Item > UI > Windows Form
Give it a name "Form1"
You should get an Alert, Click Yes and wait few sec untill the code is created for the form
Now we Create our Main() Function which is being called when DLL is injected in the game
copy and paste this code in Form1.cpp after your #include's
Code:
//MyDLL is the name of your Project. If your Project is called
//MapleHaxV1 you'll need to change MyDLL to using namespace MapleHaxV1
using namespace MyDLL;
[STAThreadAttribute]
int Main()
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
// Create the main window and run it
Application::Run(gcnew Form1()); //Form1 is the name of the form created.
//if named different replace Form1 With the right form name.
return 0;
}
If you go back to your "MainDLL.cpp" and look at the code,
after DLL_PROCESS_ATTACH we are creating a thread that will call the "Main" function. and that function is located in Form1.cpp.
After all of that go to
Build > Build Solution (F7 shortcut)
Go to My Documents > Visual Studio 2008 > Projects > MyDLL > Debug
and you'll have your MyDLL.dll there.
Use an Injector and inject it into maplestory.
If you see a window popup then tap your self on the sholder. because you just made your 1st real DLL!
Q & A
Why not just include Form1.cpp in MainDLL.cpp?
Well that has to do with managed and unmanaged code.
in Managed code you can use all functions from the managed framework.
.NET
your form and form1.cpp are being compiled with the /clr which have full access to the .NET framework, but MainDLL doesnt.
There might be a way to make it work but heck this is much easier IMO
Tutorial by: