|
Gerben Jongerius wrote: A property could be compared to a member variable in the way you can assign a value to it or retrieve it, pending on the read and write access. A function can't do this the same way.
With a property you would get the following
class.prop = value
A function would be
class.setProp( value )
Properties can make your classes easier to understand then when you use get and set functions, however if you want to set more member variables at once a function is easier as they can have more parameters.
One more thing, FUNCTION return some value after processing, which should be collected/received/stored in variable.
|
|
|
|
|
I have developed a class and built dll (Dynamic Link Library).
I have a mechanism in this dll to detect whether the user (programmer) of this dll is authorised to use this dll in his own programs or not.
Now if the user is not authorised to use this dll, i want to delete this dll from the code within this dll in runtime (Complicated, deleting itself).
Please tell me how can I delete this dll in VB.NET 2003.
Thanx
Iftikhar Ali
http://www.itajtech.net.tc
|
|
|
|
|
The method is very easy to delete the file.What is ur real
purpose. That time I can help u. u can use the file delete
method ( Please use this function kill() )
Continue...
|
|
|
|
|
My purpose is:
If the user is not authorised to use this dll, i want to delete this dll from the code within this dll in runtime. I have developed a program whose core functionality is in this dll. Now anybody can use this dll to make a software like mine, I want to restrict anybody (except me) to use this file.
Now tell me what you think of my situation?
Please tell me with coding.
Iftikhar Ali
|
|
|
|
|
And if there is a problem with the users authentication? Boom! Too late to fix it... Better hang up the phone to tech support and reinstall the app...again.
This situation is no different than any other IP issue every developer on the planet faces. There is a reason why no other developer on the planet is doing this.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
OK! I stick to this approach of not processing any unauthorised request.
Is it OK?
Iftikhar Ali
|
|
|
|
|
How to use kill() in any dll.
Give example with coding of any dummy dll.
Iftikhar Ali
|
|
|
|
|
Iftikhar Ali wrote: Now if the user is not authorised to use this dll, i want to delete this dll from the code within this dll in runtime
A better method would simply be to not process any requests for methods/properties on your class. Self-destructing is not a very friendly way to do things, besides, your DLL will be in use and cannot be deleted. All locks must first be released.
...Steve
"Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life."
(Translation: I'll show you the way, but not write the code for you.)
I read that somewhere once
|
|
|
|
|
As far as I know somebody post an article of Update exe from within the code of same exe.
So I think it is possible, but I'm at present on the same side as you suggested, ie. not to process any information.
[Give reply with code PLEASE!]
Iftikhar
|
|
|
|
|
Iftikhar Ali wrote: I'm at present on the same side as you suggested, ie. not to process any information.
Excellent decision!
Iftikhar Ali wrote: [Give reply with code PLEASE!]
This is very simple. You should be able to work this out on your own. Just detect whether or not the caller is authorized either on each method/property call or a global variable set during such detection at DLL load time and accept or deny the action accordingly. Dave K. has already stated this in a separate reply to your original post.
...Steve
"Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." (Translation: I'll show you the way, but not write the code for you.) I read that somewhere once
|
|
|
|
|
Yeah I know how it works.
But will you please tell me how to make a dll which when load detect whether its legal or not.
Tell me
Dim myClass1 as new myClass(???)
how can i get some string or anything right when my class is initialize as above, in place of ??? like this
Dim myClass1 as new myClass("XYZ")
Thanx
Iftikhar Ali
|
|
|
|
|
Iftikhar Ali wrote: Yeah I know how it works.
Great!
Iftikhar Ali wrote: But will you please tell me how to make a dll which when load detect whether its legal or not.
Tell me
Uhhh.... you tell me I'm not being a smart-arse here, it's just that YOU are the one who knows the method by which you are authorizing the use of your DLL. I's not up to me to provide this.
Iftikhar Ali wrote:
Dim myClass1 as new myClass(???)
how can i get some string or anything right when my class is initialize as above, in place of ??? like this
Dim myClass1 as new myClass("XYZ")
I'm not sure I understand what you mean. Please elaborate.
As for the DLL coding, this is covered in many places and there are a few references on the Code Project articles section as well as Microsoft's MSDN website.
...Steve
"Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." (Translation: I'll show you the way, but not write the code for you.) I read that somewhere once
|
|
|
|
|
Steve Pullan wrote: As for the DLL coding, this is covered in many places and there are a few references on the Code Project articles section as well as Microsoft's MSDN website.
I will goto MSDN and search there, nonetheless Thanx for all suggestions.
Iftikhar Ali
|
|
|
|
|
You can't delete the .DLL while it's loaded into a process, period. There's no way around this. If your code was it's own .EXE, that's a different story, but a .DLL has no chance of deleting itself.
Since you already have the mechanism to determine if the user is authorized, it's simple. On each of your method calls, or just the very important ones, run your check or check a flag that your authorization code sets, and return nothing if that check fails.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
If you load the dll from another assembly into its own AppDomain, you can turn Shadow Copying on. Shadow copying copies the dll to a temp directory. This would obfuscate the location of the DLL once you've self-destructed, but you'd still have the DLL floating around in the temp dir.
|
|
|
|
|
Yep, that's true, and I think the point of his "security feature" is to remove all traces of the .DLL, so that wouldn't work for him.
Why on earth you would want to do something like this "feature" is beyond me...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Look at codesecurity, obfuscation and authenticating to a server. Probably the best way to keep your users from continuing to use your DLL is by generating a key that is generated from machine specific (BIOS) values, having them send it to you, and then you sending a 'public key' back. The other way is to authenticate every call to your server, but this would only work well for DLLs that already talk to networks outside its own.
Ultimately, unless you are writing code that unlocks the keys of the universe, you're best off obfuscating your code and using simple time countdown techniques.
Andrew
|
|
|
|
|
Don't tell me! Tell the OP! He's the one that wants to do this, not me!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
You need to get your OP to start reading this forum and get him to realize that you can't put together ghastly hacks like this. Your users will resent you (see Sony's fiasco with its copy protection trojan) and developers will not respect you. This is something that many technology managers fail to think about, the code that they represent. Many of them seem to think that all of their problems are outside of the code.
Andrew Peters
|
|
|
|
|
Yeah I know that. But from deep within my heart, I think why any unauthorised programmer can make the same program like mine with my dll. I want destroy the very basis of that illegal program by deleting my own dll.
I have no intention of selling or giving that dll, so the matter of "developers will not respect me" is over right here.
Iftikhar Ali
|
|
|
|
|
AndrewPeters wrote: Look at codesecurity, obfuscation and authenticating to a server. Probably the best way to keep your users from continuing to use your DLL is by generating a key that is generated from machine specific (BIOS) values, having them send it to you, and then you sending a 'public key' back.
Tell me about this in detail, PLEASE! with coding.
AndrewPeters wrote: Ultimately, unless you are writing code that unlocks the keys of the universe, you're best off obfuscating your code and using simple time countdown techniques.
Whats countdown techniques, please tell me in detail.
Iftikhar Ali
|
|
|
|
|
Just to make my dll more secure and destroying the software (its base) of that illegal user.
What you think? I think its a right of every programmer.
Iftikhar Ali
|
|
|
|
|
A right? Maybe.
Practical from a developers perspective? Definitly not...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I don't want anybody (Ofcourse except me) to use my dll.
Its clear now.
Now tell me what should I do? (With professional look)
Iftikhar Ali
|
|
|
|
|
Iftikhar Ali wrote: I don't want anybody (Ofcourse except me) to use my dll.
Just look at how Microsoft (or ANY developer for that matter) has had code pirated over the years. You can only do so much before it becomes too hard and impractical.
Iftikhar Ali wrote: Now tell me what should I do?
Rather demanding aren't you? Just do what we've been advising you to do and that's do a check when your DLL is loaded and then return nothing from any method/property call. There's nothing difficult about this. Follow the leads we have given you and do some research.
If you have a problem with a bit of code you have written, we will certainly have a look and advise what to do, but we will not write it for you.
Iftikhar Ali wrote: (With professional look)
...Steve
"Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." (Translation: I'll show you the way, but not write the code for you.) I read that somewhere once
|
|
|
|