I'm not familiar with programming bots so I try to accomplish subgoals.
Currently I attempt to inject a DLL into Silkroad Online.
My program works fine with applications like Paint, Editor and Mozilla Firefox.
Unfortunately Silkroad is the only program it does not work with so far.
Programming language: C++
Game: Silkroad Online
Can you tell me why it doesn't work?
Thanks in advance!
My DLL:
Code:
#include <windows.h>
BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD reason, LPVOID reserved)
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
MessageBox(NULL, "Hi!", NULL, MB_OK);
break;
case DLL_PROCESS_DETACH:
MessageBox(NULL, "See ya!", NULL, MB_OK);
break;
}
return TRUE;
}
Code:
#include <windows.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
string DLL = "..." + '\0';
HWND SRO_Client;
for (;;)
{
SRO_Client = FindWindow(NULL, "SRO_Client");
if (SRO_Client != NULL)
{
break;
}
Sleep(5000);
}
DWORD PID;
GetWindowThreadProcessId(SRO_Client, &PID);
HANDLE hToken;
TOKEN_PRIVILEGES tkp;
if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
{
LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &tkp.Privileges[0].Luid);
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken, 0, &tkp, sizeof(tkp), NULL, NULL);
}
HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, PID);
LPVOID hRemoteMem = VirtualAllocEx(hProc, NULL, DLL.size(), MEM_COMMIT, PAGE_READWRITE);
DWORD numBytesWritten;
WriteProcessMemory(hProc, hRemoteMem, DLL.c_str(), DLL.size(), &numBytesWritten);
HMODULE hLocKernel32 = GetModuleHandle("Kernel32");
FARPROC hLocLoadLibrary = GetProcAddress(hLocKernel32, "LoadLibraryA");
HANDLE hRemoteThread = CreateRemoteThread(hProc, NULL, 0, (LPTHREAD_START_ROUTINE)hLocLoadLibrary, hRemoteMem, 0, NULL);
WaitForSingleObject(hRemoteThread, 10000);
VirtualFreeEx(hProc, hRemoteMem, DLL.size(), MEM_RELEASE);
CloseHandle(hProc);
Sleep(5000);
return 1;
}







