Skip to content

Instantly share code, notes, and snippets.

@knowlet
Last active August 29, 2015 14:05
Show Gist options
  • Save knowlet/ee4f12d6a261188f4ec5 to your computer and use it in GitHub Desktop.
Save knowlet/ee4f12d6a261188f4ec5 to your computer and use it in GitHub Desktop.
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#define jmp(frm,to) (((int)to - (int)frm)-5)
int MemWrite(LPVOID pxAddress,PBYTE code,int size)
{
unsigned long Protection, Ret;
VirtualProtect((LPVOID)pxAddress,size,PAGE_READWRITE,&Protection);
Ret = memcpy((LPVOID)pxAddress,(const LPVOID )code,size);
VirtualProtect((LPVOID)pxAddress,size,Protection,0);
return Ret;
}
int hookGetAdaptersInfo() {
DWORD GetAdaptersInfo_Adr = 0;
printf("Getting GetAdaptersInfo Address..." );
do
{
Sleep(1000);
GetAdaptersInfo_Adr = (DWORD)GetProcAddress(GetModuleHandle("Iphlpapi"), "GetAdaptersInfo");
}
while(!GetAdaptersInfo_Adr);
printf("\rGetAdaptersInfo's Adr: %p\n", GetAdaptersInfo_Adr);
printf("Hook: %p", MemWrite((LPVOID)GetAdaptersInfo_Adr, (PBYTE)"\xC2\x08\x00", 3));
printf("Loading MultiMS DLL... ");
puts((PostMessageA((HWND)FindWindow("StartUpDlgClass", "MapleStory"), WM_CLOSE, 0, 0) && LoadLibrary("multi.dll") != NULL) ? "DLL Loaded\nMulti MS Successful!" : "DLL Load Faild.");
return 0;
}
BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ ,
DWORD reason /* Reason this function is being called. */ ,
LPVOID reserved /* Not used. */ )
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
AllocConsole();
freopen("CONOUT$", "w+t", stdout);
freopen("CONIN$", "r+t", stdin);
printf("HelloWorld!\n");
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)hookGetAdaptersInfo, NULL, 0, NULL);
break;
case DLL_PROCESS_DETACH:
FreeConsole();
ExitProcess(0);
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
/* Returns TRUE on success, FALSE on failure */
return TRUE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment