Packet Injection
I'm trying to make a bot to automatically feed my pet in Ragnarok Online. So far I've been quite successful in everything I've tried however I can't quite figure out how to send a packet using that games socket. Below is my code to read the food value of the pet. After much googleing I think what I'm trying to do can be done with raw sockets however I've found nothing about it. I'm not looking for someone to do this for me, simply a link to a msdn function that can do what I'm trying is more what I'm looking for.
Code:
#include <Windows.h>
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;
void error(int errorid){
switch (errorid)
{
case 0:
cout << "Couldn't find window." << endl;
break;
case 1:
cout << "Couldn't open process." << endl;
default:
break;
}
exit(errorid);
}
int main(){
const char* name = "Ragnarok Online"; //window name
const DWORD address = 0x9B224C; //address food is stored in
HWND hwnd; //window handle
DWORD pid; //process id
HANDLE handle; //program starting address(?)
DWORD food; //used to store our pets current food value
cout << name << endl;
hwnd = FindWindow(NULL, name);
if (!hwnd)
error(0);
GetWindowThreadProcessId(hwnd, &pid);
handle = OpenProcess(PROCESS_ALL_ACCESS, false, pid);
if (!handle)
error(1);
while (true)
{
ReadProcessMemory(handle, (LPCVOID)address, &food, 4, NULL);
if (cin.peek())
{
string input;
cin >> input;
if (input == "food")
{
cout << "Pet's current food is: " << food << endl;
}
else
{
cout << "Unknown Command!";
}
}
}
return 0;
}

but..