tcp and udp is completely irrelevant. i don't know why the hell anyone would bring that up.
the reason you're getting disconnected is most likely one of 2 reasons:
1) the data you sent is deemed too unlikely by the server (for example if you moved 100000 pixels in one tick, it's an obvious lie). the server may have done some sort of detection for this and disconnected you in return
2) the packet you have sent was not accepted because you did not update the header for timestamp, packet number, etc. so it was deemed invalid.
there has been a lot of BS and misinformation in this thread so far from people not knowing what they're talking about and acting like they do.
it is critical for you to understand how a game works and then that will help you figure out why things aren't working. let me give you a brief overview. in most games, it follows a model that goes something like this:
- we have a server: this server holds the 'world state' of most things about the game. the game is all about changing this 'state' to be favourable to you. from a legitimate point of view, the server allows certain changes by listening to certain packets which instruct it to do certain things. (eg. i won 100 gold, my client sends packet to server telling it this and the server updates the state to reflect that)
- we have n clients: all the clients interact with the server with a predetermined protocol. by protocol i don't mean at the udp/tcp level but from a packet descriptor/content level. the server is only going to accept and act upon packets received that are in a certain format with certain data at expected places
so you have to think how this all works. when your client receives input, (like a key down), it translates that to some sort of game event. if that game event results in a change of world state, it sends a corresponding packet to the server. that packet is most likely not only contains the information necessary to notify the server what has happened but also unique information, like timestamps, etc. when the server receives the packet, it can choose to act upon it, most likely performing some sort of validation first to see if it seems legitimate.
from this, you can probably see there are actually several places you could hook. in fact, it's probably smarter to hook the game events instead and let the client deal with all the timestamping, encryption, etc. that's why most packet editors for games will hook the game 'api' or functions which are wrapping the networking functions. how to find these is generally a case of reverse engineering and you must have a certain competence with the assembly language to do so.
this is all general and only one model which games follow. another common model allows certain information to be stored by a 'master' or 'key-holder' of a game. for example, in FPS games or games which have 'rooms', this is often the case. in this case, that person's computer acts sort of like the server in some senses, holding a lot of the 'room state' information. which is why some hacks require you to be key-holder to perform.