Quote:
Originally Posted by !crazyangel!
the author says that i dont even know how it works well i do
im a c++ coder too but all im saying is something wrong i found in the source code the blacknull code but i think something is wrong about it
|
Oh, there might be something wrong with the injector then? Well, you can compare it with my working one then (if you wish). It's old, but it works for The Warlords and Conquer Online.
Code:
// Include Local Library Headers:
#include "Project.h"
#define CREATE_PROCESS_NO_FLAGS 0
#define CREATE_AND_RUN_THREAD 0
/* This method injects the hook library into the target process. */
bool Inject(void* process, char* dllName);
/* This function defines the entry point for the injection application. It starts a new instance of
* the client using the create process function, then injects the connection hook into the process
* using the hook library. */
int main(int argc, char* argv[])
{
// Initialize Local-Scope Constants:
const string TARGET("TheWarlords.exe blacknull");
// Initialize Local-Scope Variables:
PROCESS_INFORMATION* processInfo = new PROCESS_INFORMATION();
STARTUPINFOA* startupInfo = new STARTUPINFOA();
// Create the process:
if (!CreateProcessA(NULL, LPSTR(TARGET.c_str()), NULL, NULL, FALSE,
CREATE_PROCESS_NO_FLAGS, NULL, 0, &*startupInfo, &*processInfo))
MessageBoxA(NULL, LPCSTR(string("Could not inject the hook library into the \ntargetted executable: ")
.append(TARGET).c_str()), "Invalid Target Executable!", MB_OK);
// Inject the DLL into the process:
else if (!Inject(processInfo->hProcess, "Client Hook.dll"))
MessageBoxA(NULL, "Sorry, the injection was unsuccessful.", "Library could not be injected!", MB_OK);
// Dispose of local-scope variables:
delete processInfo;
delete startupInfo;
return 0;
}
/* This method injects the hook library into the target process. */
bool Inject(void* process, char* dllName)
{
// Allocate memory to write in the file name to the process:
int length = strlen(dllName);
void* memoryPtr = VirtualAllocEx(process, NULL, length, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
// Write the DLL file name to the process and ensure it was successful:
WriteProcessMemory(process, memoryPtr, dllName, length, NULL);
void* injectorPtr = GetProcAddress(GetModuleHandleA("kernel32.dll"), "LoadLibraryA");
if (injectorPtr == NULL) return false;
// Create the remote thread in the process to check that the program didn't crash.
Sleep(1000); // Wait a full second for the program to load the library.
void* thread = CreateRemoteThread(process, NULL, 0, LPTHREAD_START_ROUTINE(injectorPtr),
memoryPtr, CREATE_AND_RUN_THREAD, NULL);
if (thread == NULL) return false;
// Wait for the thread to process data. If it times out, the program crashed.
int result = WaitForSingleObject(thread, 10000);
if (result == WAIT_ABANDONED || result == WAIT_TIMEOUT || result == WAIT_FAILED)
{
// The thread timed out. The injection didn't hook properly.
if (thread != NULL) CloseHandle(thread);
return false;
}
// The injection was successful.
// Wait for the objects to finish testing the thread, then dispose of the thread.
Sleep(1000);
if (thread != NULL) CloseHandle(thread);
return true;
}