private void LoadSetChatTextOpcode() { //Allocate memory for the opcode to call the setChatText function _setChatTextOpcodeAddress = MemFunctions.AllocateMemory(_client.Handle, _setChatTextOpcode.Length); //Write the opcode to memory MemFunctions.MemWriteBytes(_client.Handle, _setChatTextOpcodeAddress, _setChatTextOpcode); // @TODO: Get the 0x44 with regex? (CALL DWORD PTR DS:[EAX+44]) }
private void LoadSendChatOpcode() { //Allocate memory for the opcode to call the sendChat function _sendChatOpcodeAddress = MemFunctions.AllocateMemory(_client.Handle, _sendChatOpcode.Length); //Write the opcode to memory MemFunctions.MemWriteBytes(_client.Handle, _sendChatOpcodeAddress, _sendChatOpcode); //Calculate relative call address of sendChat() uint relAddress = SendChatCall - (uint)_sendChatOpcodeAddress - 12 - (uint)(_sendChatOpcode.Length / 2); //Insert the functionAddress in opcode byte[] functionAddress = BitConverter.GetBytes(relAddress); MemFunctions.MemWriteBytes(_client.Handle, _sendChatOpcodeAddress + 22, functionAddress); uint chatClassPtr = MemFunctions.ResolveNestedPointer(_client.Handle, BaseCall, 0x1C, 0x18, 0x8, 0xC4, 0x20, 0); byte[] chatClassPtrBytes = BitConverter.GetBytes(chatClassPtr); MemFunctions.MemWriteBytes(_client.Handle, _sendChatOpcodeAddress + 13, chatClassPtrBytes); }
// Just updates the variable information in the opcode without reallocating the whole opcode // to another memory location private void UpdateSetChatTextOpcode(string str) { Encoding unicode = Encoding.Unicode; byte[] unicodeBytes = unicode.GetBytes(str); //Allocate memory for the chat message int chatMsgAddress = MemFunctions.AllocateMemory(_client.Handle, unicodeBytes.Length); // Write the message to memory MemFunctions.MemWriteBytes(_client.Handle, chatMsgAddress, unicodeBytes); // Write the address of the string pointer byte[] stringAddr = BitConverter.GetBytes(chatMsgAddress); MemFunctions.MemWriteBytes(_client.Handle, _setChatTextOpcodeAddress + 2, stringAddr); // Get the pointer to the chat input box object uint chatBoxObjPtr = MemFunctions.ResolveNestedPointer(_client.Handle, BaseCall, 0x1C, 0x18, 0x8, 0xC4, 0x20, 0x1C4, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x08, 0); byte[] chatBoxObjPtrBytes = BitConverter.GetBytes(chatBoxObjPtr); MemFunctions.MemWriteBytes(_client.Handle, _setChatTextOpcodeAddress + 7, chatBoxObjPtrBytes); }
private int LoadAppendCharOpcode() { //Allocate memory for the opcode to call the sendChat function _appendCharOpcodeAddress = MemFunctions.AllocateMemory(_client.Handle, _appendCharOpcode.Length); //Write the opcode to memory MemFunctions.MemWriteBytes(_client.Handle, _appendCharOpcodeAddress, _appendCharOpcode); //Calculate relative call address of chatBoxKeyHandler() uint relAddress = ChatBoxKeyHandlerCall - (uint)_appendCharOpcodeAddress - 9 - (uint)(_appendCharOpcode.Length / 2); //Insert the functionAddress in opcode byte[] functionAddress = BitConverter.GetBytes(relAddress); MemFunctions.MemWriteBytes(_client.Handle, _appendCharOpcodeAddress + 15, functionAddress); // Get and load the pointer to the chat system class uint chatEntryBoxObjPtr = MemFunctions.ResolveNestedPointer(_client.Handle, BaseCall, 0x1C, 0x18, 0x8, 0xC4, 0x20, 0x1C4, 0xC, 0xC, 0xC, 0xC, 0xC, 0xC, 0xC, 0xC, 0x8, 0); byte[] chatEntryBoxObjPtrBytes = BitConverter.GetBytes(chatEntryBoxObjPtr); MemFunctions.MemWriteBytes(_client.Handle, _appendCharOpcodeAddress + 8, chatEntryBoxObjPtrBytes); return(_appendCharOpcodeAddress); }