All Keyboard buttons in SA:MP
#1

Hello.

I'm looking for new plugin ideas.

And I have a question. Is there any client-server plugins that allow you to control all keyboard buttons in you Pawn code(server side)?
Reply
#2

You can use some dll injections or hooks, but it only works clientside on localhost.
There is a possibility to do this. You need to write an extension with memory hacking, but thats not recommend and to display every pressed button is like creating a trojan as well as it results in an huge network drain.
If you consider it, create a hook clientside that is called everytime a key is pressed. Send the key as flag byte as RPC to the server and hook the RPC serverside. Create some queries to reduce the network drain. e.g. just record the keys if the user is in a dialog or smth like this.
Reply
#3

Quote:
Originally Posted by Alf21
View Post
You can use some dll injections or hooks, but it only works clientside on localhost.
There is a possibility to do this. You need to write an extension with memory hacking, but thats not recommend and to display every pressed button is like creating a trojan and a huge network drain
There is the better way (sockets).
But before that, I need to know, if plugins like this exist.
Reply
#4

How do you think sockets can help. That results in a much more huger network drain and performance drain. So on you also need client- and serverside plugins to hook these actions. If you can record the keys with the help of dlls, there is no memory hacking anymore. But for that there is a greater comsumption all in all.

If you pay attention to ingame Textdraw-Editors, you can find some ms dll files that hook the keys and make it possible to use the keys clientside on localhost.
Try to find these files and understand how it works and how you can use it
Reply
#5

Quote:
Originally Posted by Alf21
View Post
How do you think sockets can help. That results in a much more huger network drain and performance drain. So on you also need client- and serverside plugins to hook these actions. If you can record the keys with the help of dlls, there is no memory hacking anymore. But for that there is a greater comsumption all in all.

If you pay attention to ingame Textdraw-Editors, you can find some ms dll files that hook the keys and make it possible to use the keys clientside on localhost.
Try to find these files and understand how it works and how you can use it
Sockets help me to send information from client to server side.
Yes, I meant client-server application, such as Textdraw-Editors. I think, there won't some big problems with network.
It also needs some network tests, but I think, it will be all fine.

Do you know some client-server plugins with this release?
I don't want to create, what was created before
Reply
#6

Quote:
Originally Posted by Alf21
View Post
You can use some dll injections or hooks, but it only works clientside on localhost.
There is a possibility to do this. You need to write an extension with memory hacking, but thats not recommend and to display every pressed button is like creating a trojan as well as it results in an huge network drain.
If you consider it, create a hook clientside that is called everytime a key is pressed. Send the key as flag byte as RPC to the server and hook the RPC serverside. Create some queries to reduce the network drain. e.g. just record the keys if the user is in a dialog or smth like this.
It's very difficult to create such plugin with hacking SA:MP client side.
And also there can be some problems with every new SA:MP version.
Reply
#7

https://sampforum.blast.hk/showthread.php?tid=376758

In the category "details" you can see that the creator uses new hotkeys.
This is a result of both files (iTD.dll, msvcr100.dll).
I never did something with msvcr dlls, but i believe this is a detection to start the iTD.dll (https://msdn.microsoft.com/en-us/library/bb918180.aspx CRT startup like a hook).

if you know how the author created his iTD.dll, you just need to implement you socket solution in that and hope, that other people will download clientside files ^^
Reply
#8

Quote:
Originally Posted by Alf21
View Post
https://sampforum.blast.hk/showthread.php?tid=376758

In the category "details" you can see that the creator uses new hotkeys.
This is a result of both files (iTD.dll, msvcr100.dll).
I never did something with msvcr dlls, but i believe this is a detection to start the iTD.dll (https://msdn.microsoft.com/en-us/library/bb918180.aspx CRT startup like a hook).

if you know how the author created his iTD.dll, you just need to implement you socket solution in that and hope, that other people will download clientside files ^^
Okey, thank you very much. I will check this plugin! It will help to realese my idea.
Reply
#9

Quote:
Originally Posted by Alf21
View Post
https://sampforum.blast.hk/showthread.php?tid=376758

In the category "details" you can see that the creator uses new hotkeys.
This is a result of both files (iTD.dll, msvcr100.dll).
I never did something with msvcr dlls, but i believe this is a detection to start the iTD.dll (https://msdn.microsoft.com/en-us/library/bb918180.aspx CRT startup like a hook).

if you know how the author created his iTD.dll, you just need to implement you socket solution in that and hope, that other people will download clientside files ^^
Will you install such client plugin to get some more server capabilities?
Reply
#10

Quote:
Originally Posted by Alf21
Посмотреть сообщение
I created samp extensions to do this, but only a small amount of people wanted to download it.
If you want that people download it, you need a performance test to show that there are no issues and you need to make the code open-source. Otherwise the most amount of people could believe that it is a trojan or virus.

So sure, i would test it but it should be open-source - sorry :/. Try GitHub.
I want to do open-source project. In GitHub. I don't have own samp-server.
It's only for my own practice in programming
Reply
#11

So, there aren't such open-source plugins for windows+linux at the moment?
Reply
#12

There was an attempt for it and it failed + locked.
https://sampforum.blast.hk/showthread.php?tid=268671
You can read the comments why.
Reply
#13

Quote:
Originally Posted by KrYpToDeN
View Post
It's very difficult to create such plugin with hacking SA:MP client side.
And also there can be some problems with every new SA:MP version.
If this data is read out from GTA game memory not samp client memory, then new version does'nt matter, gta game exe will remain the same, and if memory location is fixed address, its quite easy to read.

Anyway its a bad way to do that.
Reply
#14

Quote:
Originally Posted by KrYpToDeN
Посмотреть сообщение
It's only for my own practice in programming
Then maybe you can start by trying to read it out from the memory (using CheatEngine for example...).
What prog. language you are using?
Reply
#15

I agree. But i believe a first try would be very great. I would use it.

Here is my old code of getting the keys (for that you need to hook the window instance of gta-sa(mp)):

Keyboard.h
Код:
#pragma once
namespace Keyboard {
	void WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
	void AddKey(BYTE byteType, BYTE byteKey);
};
Keyboard.cpp
Код:
#include "Keyboard.h"
//... includes like LiteRPC for memory hacking UDP connection of SAMP - instead use ur socket

bool CaptureKey[KEYBOARD_MAX_KEYS] = { 0 };

void Keyboard::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) // call this on WndProc of your GTA-SA(MP) instance
{
	switch (uMsg)
	{
		case WM_KEYUP:
		{
			if (wParam < 0 || wParam > KEYBOARD_MAX_KEYS)
				break;

			BYTE byteKey = static_cast<BYTE>(wParam);

			// get the char of pressed key
			DWORD dwProcessId = GetWindowThreadProcessId(hWnd, NULL);
			HKL dwhkl = GetKeyboardLayout(dwProcessId);
			BYTE vks[KEYBOARD_MAX_KEYS + 1];
			WORD w;
			GetKeyboardState(vks);
			int result = ToAsciiEx((unsigned short int)wParam, HC_ACTION, vks, &w, 0, dwhkl);

			if (CaptureKey[byteKey])
			{
				DEBUG_OUT("SENDING KEY %x with char %c\n", byteKey, (char)w);
				RPCS::Keyboard::SendKey(byteKey, w); // RPC sending key, you could use ur socket
			}

			break;
		}
	}
}

void Keyboard::AddKey(BYTE byteType, BYTE byteKey) // such a register to not spam the key
{
	if (byteKey < 0 || byteKey > KEYBOARD_MAX_KEYS)
		return;

	DEBUG_OUT("ADDING KEY %x\n", byteKey);

	switch (byteType)
	{
	case 0: // register
		CaptureKey[byteKey] = true;
		break;
	case 1: // unregister
		CaptureKey[byteKey] = false;
		break;
	}
}
and my keyids with defines to handle more easier:
Код:
#define KEYBOARD_MAX_KEYS 255                   // Maximal amount of added keys

// VK_[KEYNAME]: Defines of Keynames with hexadecimal of them (0-255)

#define	VK_LBUTTON 					0x01
#define	VK_RBUTTON 					0x02
#define VK_CANCEL  					0x03
#define VK_MBUTTON  				0x04
#define VK_MOUSE_MID  				0x04
#define VK_XBUTTON1 				0x05
#define VK_MOUSE_LEFT 				0x05
#define VK_XBUTTON2 				0x06
#define VK_MOUSE_RIGHT 				0x06
// undefined: 0x07
#define VK_BACK  					0x08
#define VK_TAB  					0x09
// reserved: 0x0A-0B
#define VK_CLEAR  					0x0C
#define VK_RETURN  					0x0D
// undefined: 0x0E-0F
#define VK_SHIFT  					0x10
#define VK_CONTROL 					0x11
#define VK_MENU  					0x12
#define VK_PAUSE  					0x13
#define VK_CAPITAL 					0x14
#define VK_KANA  					0x15
#define VK_HANGUEL 					0x15
#define VK_HANGUL  					0x15
// undefined: 0x16
#define VK_JUNJA  					0x17
#define VK_FINAL  					0x18
#define VK_HANJA  					0x19
#define VK_KANJI  					0x19
// undefined: 0x1A
#define VK_ESCAPE  					0x1B
#define VK_CONVERT  				0x1C
#define VK_NONCONVERT 				0x1D
#define VK_ACCEPT 					0x1E
#define VK_MODECHANGE 				0x1F
#define VK_SPACE  					0x20
#define VK_PRIOR  					0x21
#define VK_NEXT  					0x22
#define VK_END  					0x23
#define VK_HOME  					0x24
#define VK_LEFT  					0x25
#define VK_UP  						0x26
#define VK_RIGHT  					0x27
#define VK_DOWN  					0x28
#define VK_SELECT  					0x29
#define VK_PRINT  					0x2A
#define VK_EXECUTE  				0x2B
#define VK_SNAPSHOT  				0x2C
#define VK_INSERT  					0x2D
#define VK_DELETE  					0x2E
#define VK_HELP  					0x2F
#define VK_0  						0x30
#define VK_1   						0x31
#define VK_2   						0x32
#define VK_3   						0x33
#define VK_4   						0x34
#define VK_5   						0x35
#define VK_6   						0x36
#define VK_7   						0x37
#define VK_8   						0x38
#define VK_9   						0x39
// undefined: 0x3A-40
#define VK_A   						0x41
#define VK_B   						0x42
#define VK_C   						0x43
#define VK_D   						0x44
#define VK_E   						0x45
#define VK_F   						0x46
#define VK_G   						0x47
#define VK_H   						0x48
#define VK_I   						0x49
#define VK_J   						0x4A
#define VK_K   						0x4B
#define VK_L   						0x4C
#define VK_M   						0x4D
#define VK_N   						0x4E
#define VK_O   						0x4F
#define VK_P   						0x50
#define VK_Q   						0x51
#define VK_R   						0x52
#define VK_S   						0x53
#define VK_T   						0x54
#define VK_U   						0x55
#define VK_V   						0x56
#define VK_W   						0x57
#define VK_X   						0x58
#define VK_Y   						0x59
#define VK_Z   						0x5A
#define VK_LWIN   					0x5B
#define VK_RWIN    					0x5C
#define VK_APPS    					0x5D
// reserved: 0x5E
#define VK_SLEEP    				0x5F
#define VK_NUMPAD0 					0x60
#define VK_NUMPAD1  				0x61
#define VK_NUMPAD2  				0x62
#define VK_NUMPAD3 					0x63
#define VK_NUMPAD4 					0x64
#define VK_NUMPAD5 					0x65
#define VK_NUMPAD6 					0x66
#define VK_NUMPAD7 					0x67
#define VK_NUMPAD8 					0x68
#define VK_NUMPAD9 					0x69
#define VK_MULTIPLY 				0x6A
#define VK_ADD 						0x6B
#define VK_SEPERATOR 				0x6C
#define VK_SUBTRACT 				0x6D
#define VK_DECIMAL 					0x6E
#define VK_DIVIDE 					0x6F
#define VK_F1 						0x70
#define VK_F2 						0x71
#define VK_F3 						0x72
#define VK_F4 						0x73
#define VK_F5 						0x74
#define VK_F6 						0x75
#define VK_F7 						0x76
#define VK_F8 						0x77
#define VK_F9 						0x78
#define VK_F10 						0x79
#define VK_F11 						0x7A
#define VK_F12 						0x7B
#define VK_F13 						0x7C
#define VK_F14 						0x7D
#define VK_F15 						0x7E
#define VK_F16 						0x7F
#define VK_F17 						0x80
#define VK_F18 						0x81
#define VK_F19 						0x82
#define VK_F20 						0x83
#define VK_F21 						0x84
#define VK_F22 						0x85
#define VK_F23 						0x86
#define VK_F24 						0x87
// unassigned: 0x88-8F
#define VK_NUMLOCK 					0x90
#define VK_SCROLL 					0x91
// OEM specific: 0x91-96
// unassigned: 0x97-9F
#define VK_LSHIFT 					0xA0
#define VK_RSHIFT 					0xA1
#define VK_LCONTROL 				0xA2
#define VK_RCONTROL 				0xA3
#define VK_LMENU 					0xA4
#define VK_RMENU 					0xA5
#define VK_BROWSER_BACK 			0xA6
#define VK_BROWSER_FORWARD 			0xA7
#define VK_BROWSER_REFRESH 			0xA8
#define VK_BROWSER_STOP 			0xA9
#define VK_BROWSER_SEARCH 			0xAA
#define VK_BROWSER_FAVORITES 		0xAB
#define VK_BROWSER_HOME 			0xAC
#define VK_VOLUME_MUTE 				0xAD
#define VK_VOLUME_DOWN 				0xAE
#define VK_VOLUME_UP 0xAF
#define VK_MEDIA_NEXT_TRACK 		0xB0
#define VK_MEDIA_PREV_TRACK 		0xB1
#define VK_MEDIA_STOP 				0xB2
#define VK_MEDIA_PLAY_PAUSE 		0xB3
#define VK_LAUNCH_MAIL 				0xB4
#define VK_LAUNCH_MEDIA_SELECT 		0xB5
#define VK_LAUNCH_APP1 				0xB6
#define VK_LAUNCH_APP2 				0xB7
// reserved: 0xB8-B9
#define VK_OEM_1 					0xBA
#define VK_OEM_PLUS 				0xBB
#define VK_OEM_COMMA 				0xBC
#define VK_OEM_MINUS 				0xBD
#define VK_OEM_PERIOD 				0xBE
#define VK_OEM_2 					0xBF
#define VK_OEM_3 					0xC0
// reserved: 0xC1-D7
// unassigned: 0xD8-DA
#define VK_OEM_4 					0xDB
#define VK_OEM_5 					0xDC
#define VK_OEM_6 					0xDD
#define VK_OEM_7 					0xDE
#define VK_OEM_8 					0xDF
// reserved: 0xE0
// OEM specific: 0xE1
#define VK_OEM_102 					0xE2
// OEM specific: 0xE3-E4
#define VK_PROCESSKEY 				0xE5
// OEM specific: 0xE6
#define VK_PACKET 					0xE7
// unassigned: 0xE8
// OEM specific: 0xE9-F5
#define VK_ATTN 					0xF6
#define VK_CRSEL 					0xF7
#define VK_EXSEL 					0xF8
#define VK_EREOF 					0xF9
#define VK_PLAY 					0xFA
#define VK_ZOOM 					0xFB
#define VK_NONAME 					0xFC
#define VK_PA1 						0xFD
#define VK_OEM_CLEAR 				0xFE
If you dont know how to inject this file to auto execute on start samp or gta sa, try dll injection or cleo. I would recommend dll injection like input.dll (DirectX Hook / Injection).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)