Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to delete exe/dll file from itself?

How to delete exe/dll file from itself?

Scheduled Pinned Locked Moved Visual Basic
questioncsharptutorial
29 Posts 5 Posters 13 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A AndrewPeters

    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

    D Offline
    D Offline
    Dave Kreskowiak
    wrote on last edited by
    #8

    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

    A 1 Reply Last reply
    0
    • D Dave Kreskowiak

      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

      A Offline
      A Offline
      AndrewPeters
      wrote on last edited by
      #9

      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

      I 1 Reply Last reply
      0
      • J Jeeva Jose

        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...

        I Offline
        I Offline
        Iftikhar Ali
        wrote on last edited by
        #10

        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

        D 1 Reply Last reply
        0
        • S Steve Pullan

          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 :-)

          I Offline
          I Offline
          Iftikhar Ali
          wrote on last edited by
          #11

          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

          S 1 Reply Last reply
          0
          • D Dave Kreskowiak

            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

            I Offline
            I Offline
            Iftikhar Ali
            wrote on last edited by
            #12

            Dave Kreskowiak wrote:

            You can't delete the .DLL while it's loaded into a process, period. There's no way around this.

            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. Iftikhar Ali

            D 1 Reply Last reply
            0
            • A AndrewPeters

              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.

              I Offline
              I Offline
              Iftikhar Ali
              wrote on last edited by
              #13

              Please tell me this in detail (Since I'm not CHEETAH in VB.NET) with coding. I think after going through your process, the best way is that delete (empty) temp files folder. Is this possible? Iftikhar Ali

              1 Reply Last reply
              0
              • D Dave Kreskowiak

                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

                I Offline
                I Offline
                Iftikhar Ali
                wrote on last edited by
                #14

                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

                D 1 Reply Last reply
                0
                • A AndrewPeters

                  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

                  I Offline
                  I Offline
                  Iftikhar Ali
                  wrote on last edited by
                  #15

                  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

                  1 Reply Last reply
                  0
                  • A AndrewPeters

                    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

                    I Offline
                    I Offline
                    Iftikhar Ali
                    wrote on last edited by
                    #16

                    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

                    1 Reply Last reply
                    0
                    • I Iftikhar Ali

                      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

                      S Offline
                      S Offline
                      Steve Pullan
                      wrote on last edited by
                      #17

                      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 :-)

                      I 1 Reply Last reply
                      0
                      • S Steve Pullan

                        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 :-)

                        I Offline
                        I Offline
                        Iftikhar Ali
                        wrote on last edited by
                        #18

                        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

                        S 1 Reply Last reply
                        0
                        • I Iftikhar Ali

                          Dave Kreskowiak wrote:

                          You can't delete the .DLL while it's loaded into a process, period. There's no way around this.

                          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. Iftikhar Ali

                          D Offline
                          D Offline
                          Dave Kreskowiak
                          wrote on last edited by
                          #19

                          Supply the link to article. I think you're mis-understanding what it says, because you cannot overwrit a file that is locked by another process, or your own process for that matter. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                          I 1 Reply Last reply
                          0
                          • I 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

                            D Offline
                            D Offline
                            Dave Kreskowiak
                            wrote on last edited by
                            #20

                            A right? Maybe. Practical from a developers perspective? Definitly not... RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                            I 1 Reply Last reply
                            0
                            • I Iftikhar Ali

                              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

                              S Offline
                              S Offline
                              Steve Pullan
                              wrote on last edited by
                              #21

                              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 :-)

                              I 1 Reply Last reply
                              0
                              • I Iftikhar Ali

                                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

                                D Offline
                                D Offline
                                Dave Kreskowiak
                                wrote on last edited by
                                #22

                                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

                                I 1 Reply Last reply
                                0
                                • D Dave Kreskowiak

                                  Supply the link to article. I think you're mis-understanding what it says, because you cannot overwrit a file that is locked by another process, or your own process for that matter. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                                  I Offline
                                  I Offline
                                  Iftikhar Ali
                                  wrote on last edited by
                                  #23

                                  Sorry, but I didn't remember the link and I use two VB.NET forums & MSDN so it is difficult for me to remember. I think it is on MSDN. But its possible. Maybe you don't know it. Iftikhar Ali

                                  1 Reply Last reply
                                  0
                                  • D Dave Kreskowiak

                                    A right? Maybe. Practical from a developers perspective? Definitly not... RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                                    I Offline
                                    I Offline
                                    Iftikhar Ali
                                    wrote on last edited by
                                    #24

                                    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

                                    S 1 Reply Last reply
                                    0
                                    • D Dave Kreskowiak

                                      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

                                      I Offline
                                      I Offline
                                      Iftikhar Ali
                                      wrote on last edited by
                                      #25

                                      OK! I stick to this approach of not processing any unauthorised request. Is it OK? Iftikhar Ali

                                      1 Reply Last reply
                                      0
                                      • S Steve Pullan

                                        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 :-)

                                        I Offline
                                        I Offline
                                        Iftikhar Ali
                                        wrote on last edited by
                                        #26

                                        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

                                        1 Reply Last reply
                                        0
                                        • J Jeeva Jose

                                          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...

                                          I Offline
                                          I Offline
                                          Iftikhar Ali
                                          wrote on last edited by
                                          #27

                                          How to use kill() in any dll. Give example with coding of any dummy dll. Iftikhar Ali

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups