Reputation: 4399
Question: I'd like to know if I would need to ask for specific permissions and/or do something extra to make it "trustworthy" in case my program copies a dll file multiple times to the temp directory. If I do this, would the program be picked up as malicious software by anti-viruses?
Sample Code:
if (needANewCopyOfTheDll)
{
string fileName = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".dll";
// Here, copy my dll to the new file.
}
But why? I have a static library written in C++, and it has global variables, initialization procedures, and so many other stuff. I'd like to have different instances of that library and I can only load the same dll once in the memory. Thus I was thinking of wrapping the library in an instance class, and when I needed a new instance of it just copy the dll file to the temp directory and get a new handle for it using LoadLibrary()
function in kernel32.dll
Upvotes: 0
Views: 179
Reputation: 186
Copying to the temporary directory does not require any special permissions. You can just do it, it should be no problem. Lots of programs do that.
It's not clear from your question whether your software is picked up as malicious or not. If it is, I suspect it is because you're loading a dll from the temporary directory.
What you do sounds like a pretty big hack anyway. You should rather rewrite your library to not use global variables.
Upvotes: 1