It is impossible to completely prevent piracy.
You must accept that your code will run on other people's machines. Those people can take your code on their machines and do anything with it, including change and (illegally) redistribute it.
You can leverage your country's legal system if you believe your rights have been infringed upon; e.g., an American citizen can issue a DMCA takedown request against an entity that is distributing his work. However, it will be more difficult to dismantle an international distributed network, such as those composed of torrent links.
Alternatively, you can revise your philosophy on software distribution. Considering it is already possible for your users to do anything with your program, you could accept that reality. Then, embrace that reality, and grant your users the freedom to run, copy, distribute, study, change and improve your software. This is typically accomplished by declaring your program "free software" (and when I say "free," am I speaking in terms of "freedom and liberty," not in terms of "price").
Releasing your program as "free software" has numerous advantages:
- Your users will easily be able to modify your program.
- If you appreciate their modifications, you can merge them back into the main project, and it will be more valuable as a result.
- If I was to modify your program, the first thing I would do would be to remove the advertisements, because I find them quite annoying. You could take this as an indication that your application would be better without advertisements, which would spur you to imagine a better revenue model ("better" both in terms of pleasing your users and profit).
- Your users will be free to redistribute your program.
- If you want your program to "go viral," removing all legal barriers to virality would be a good thing.
- People can already redistribute your program. Either they are "evil," or they are benevolent for sharing things with their neighbors, which is a basic human trait that makes us more successful than species without compassion. Now they can feel good about it, as they should.
- Other people will be able to study your work and learn from it.
- I learned a tremendous amount about programming from trudging through the source of RPGMaker games, for which the game code is usually free to browse. In fact, I am aware that a whole community of game developers have emerged from sharing and learning things from each others' code, and have grown up and are leading successful careers and delivering high-quality products. You can be happy knowing that your program has benefited more people than just you.
Making your program "proprietary," as you intend to do, gives you the false reassurance that people must first pay you in order to obtain and use your software. You are aware that this is not true, due to piracy.
So consider the converse: What if you offered the software to the customers first, and told them that if they derived value from it, then they would pay you?
If an "honest" person was willing to pay you for your software before he could use it, then (as long as you are providing a high quality product) why should he not be just as willing to pay you after he has enjoyed it? (I paid the author of Chrome's AdBlock plugin, which is free software available gratis, because I derived immense value from it.)
As for a "dishonest" person who would download a modified version of your program from an illegal source, he is certainly not willing to pay up-front. Now you have the opportunity to capture revenue from that person, because the "freeloader" might derive value from your program and then decide to pay you. If pirates pose a considerable "threat" to your program, you might consider turning the tables such that your pirates become potential customers instead.
I recommend the "free software" approach. You could continue to create proprietary software and you would still probably make plenty of money, as many people who produce proprietary software do; though you would have to ignore the "problems," both financial and moral, which exist inevitably and incurably because of the nature of creative works. These "problems" become vehicles for the enhancement of your product when you adopt free software philosophies; you would have an edge over competitors who cannot understand this power.