Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DLL Talk / Plugin Copy Protection

Author
Message
zog
16
Years of Service
User Offline
Joined: 13th Dec 2007
Location: Southport UK
Posted: 22nd Mar 2008 08:08
How do I add copy protection to a dark basic pro plugin ?

Thanks for any help in advance


Jack Taylor

Jack Taylor
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 22nd Mar 2008 12:36
You either use a method similar to the BlueGui plug-in (startup command needing a key and password), or you sell it via TGC and they tell you how to add their copy protection scheme to your plug-in.

the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 22nd Mar 2008 20:58 Edited at: 22nd Mar 2008 20:58
Are you looking to sell the plugin to others or just use it yourself?

If you are just using it yourself there is another method.

The plugin string table is only used by the compiler to find out what commands the plugin contains. Once exe is built and the compiler has attached a copy of the plugin to the exe the string table is no longer needed.

So you can build two versions of your plugin, one with a string table and one without. Then before you distribute your exe replace the attached plugin with the one that doesn't have a string table. You can use dark_explorer to replace the attached plugin.

Now someone could get your dll from the exe but they would need a string table to use it. I guess you could also obfuscate the function names the dll exports to make it harder to reconstruct the string table.

Nobody appears to have bothered to break the weak system TGC use so I guess you would be pretty save at just removing the string table.

By way of demonstration, he emitted a batlike squeak that was indeed bothersome.
Olby
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location:
Posted: 23rd Mar 2008 18:41
@the_winch - By the way I just tried to launch Dark Explorer but it crashes on Vista. I tried setting WinXP compatibility mode - no effect. This is the information it returns:




ACER Aspire 5920G: Core2Duo 2.2GHZ, 2GB, GeForce 8600M GT 1280MB, DirectX10, DBPro 6.7
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 23rd Mar 2008 21:01
Quote: "By the way I just tried to launch Dark Explorer but it crashes on Vista."


Try downloading this new version. Hopefully it fixes the problem.

http://winch.pinkbile.com/download/dark_explorer.zip

By way of demonstration, he emitted a batlike squeak that was indeed bothersome.
Olby
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location:
Posted: 23rd Mar 2008 22:08
Nope. Still does not work.




ACER Aspire 5920G: Core2Duo 2.2GHZ, 2GB, GeForce 8600M GT 1280MB, DirectX10, DBPro 6.7
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 24th Mar 2008 01:49
Try the exe attached to this post. It's built against .net v2.0 instead of .net v1.1

If it doesn't work I'll try and find a machine with just .net v2.0 installed to test with.

By way of demonstration, he emitted a batlike squeak that was indeed bothersome.

Attachments

Login to view attachments
zog
16
Years of Service
User Offline
Joined: 13th Dec 2007
Location: Southport UK
Posted: 24th Mar 2008 12:14 Edited at: 24th Mar 2008 12:28
I am using DB Pro with vista. I have had a few issues, but I have managed to sort them out. First of all set dark basic to run as an administrator. You can do this by right clicking the dbpro exe file and editing it's properties.
To get dbpro debugger to work you need to copy MFC71.dll to

"Crogram Files (x86)The Game CreatorsDark Basic Professional OnlineCompiler directory

I have not used DarkExplorer. I use XN Resource Editor, which will allow you to edit resources as well.

http://www.wilsonc.demon.co.uk/delphi.htm

The only problem is when you edit a dark basic executable, it destroys the executable ( under windows 64 bit vista SP1 ). I get the same problem when I use my home brew copy protection system.

There are some little know windows API function calls that allow you to edit the resources of an executable once it has been compiled. These are BeginUpdateResource, UpdateResource, and Endupdate resource. I used to use these with my own home brew copy protection system. It is unfortunately these function which I am pretty sure don't work correctly on vista. I looked on the net and other people were getting similar problems to myself, under windows xp. I tried to report the problem to microsoft, but I ran into the corporate wall of denial and dis-service.

My copy protection system works like this. If I want to protect a module within an exectuable, I inject a hollow resource of a fixed length into an executable. I call this block a cyclic redunancy omission block ( CROB ). I mark each end of the block with the word CROB. I add a special string to the executable to make the executable unique with a unique licence key usually a GUID. I then create a hash of the executable for every byte, except the bytes within any CROBs, there might be more than one.

I then pass control to a separate program - this program check's that the end user has a valid licence, it can do this with an internet check.
I then generate a random string of characters to insert inside the CROB. The random number generator is seeded using the result from the hash function and the licence key. I then encrypt the garbage using a special key within my dll and store the encrypted garbage back into the crob in the executable.
When your dll loads you can load the resource of the executable that it is under. Therefore you can get the licence key, the information inside the crob and you can recalculate the hash function again. It is therefore a simple process to recreate an encrypted string of garbage and check that it matches the string inside the CROB. If the strings match your plugin is licensed if it doesn't it's not. Depending on the encryption algorithm you choose you can make it hard to crack this encryption. If you encrypt the garbage string remotely using a public private key system you can make it hard to fake the CROB string ( although I don't don't do this as it means running a server ).
The executable is locked because you can not change any part of it.
The added advantage of this copy protection system is that if one byte of the executable changes or a byte inside the crob changes; the copy protection is invalidated. This means that if the executable is attacked by a trojan it will trigger the copy protection system.

The disadvantages are that it will not work other copy protection systems that add a stub of code to an existing executable.
Anyway I thought I would make this technique public, so people can poke holes in it.

You could also store the licence keys on the internet so that an end user or os software could check to see if an exe contained valid modules.

Anyway it doesn't work any more as the update resource API is broken.

If you want to track down missing dependencies I find Depends.exe to be a very useful tool ( available from microsoft ).

Jack Taylor
Olby
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location:
Posted: 24th Mar 2008 13:22
Ok, Winch, it works smoothly now! I tried almost all functions and everything worked as expected. Thank you.


ACER Aspire 5920G: Core2Duo 2.2GHZ, 2GB, GeForce 8600M GT 1280MB, DirectX10, DBPro 6.7
zog
16
Years of Service
User Offline
Joined: 13th Dec 2007
Location: Southport UK
Posted: 24th Mar 2008 20:16 Edited at: 24th Mar 2008 20:18
Thanks winch,
I think I understand why the UpdateResource functions might not be working with a darkbasic pro exe. I had a look at your web site, specifically at the db pro executable file format.
I had no idea that a dbp exe unpacks itself to the windows temp directory.
I always imagined dbp was linking in it's code, in statically. It just goes to show you should never make assumptions.

Jack Taylor

Login to post a reply

Server time is: 2024-09-08 03:34:38
Your offset time is: 2024-09-08 03:34:38