|
|
i dont want to export function... i want to import them... like the half-life engine does it with the mod dlls!
Don't try it, just do it!
|
|
|
|
|
How would I get the F-lock to show in the status bar.
I have a microsoft keyboard so it has one of those F-lock keys.
Any help please, I use Visual C++ 6.
[It is possible to represent everything in this universe by using 0 and 1]
I'm going to live forever or die trying.
|
|
|
|
|
Hi,
I have asked questions related to this problem before, but as I may be approaching the whole problem from the wrong direction, I am hoping that I might be able to get some suggestions that will shed a new light upon it.
I am writing a file protection program (third-party) for a hobbyist game engine (though in theory it could protect any program with a number of external files). A game consists of an executable, model files, bitmap files and even script files, without protection all of which can be opened up by anyone who has the game. I would like to protect these files in such a way that nobody can access them. Currently I pack the game files in a protected ZLIB archive (using the ZipArchive library from www.artpol-software.com, and use a launcher to extract the files to a temporary folder whenever the game is started and delete them when it ends. This, of course, is hardly a solution, as all somebody has to do to access the files is alt-tab during gameplay and search for them.
Incidentally, please don't tell me not to protect the files at all. I know that there are arguments for not protecting the files - however, the versions of the engine I am writing this for have no modding capabilities, so there's no reason for a player to have access to them. More importantly, the chief concern of the hobbyist developers who will hopefully use my app is to protect their hard work from each other, as it's an unfortunate fact of life that in an online hobbyist community where many demos are posted, there will always be leeches who steal work and present it as their own if it's made easy for them...
So my question is: does anybody have any killer suggestions on how I can effectively protect these files?
My app uses the Windows API with *no* MFC, btw.
Any help/suggestions would be really appreciated.
Many thanks,
KB
|
|
|
|
|
One way to to protect the files is to use a proprietary binary format that only you program can understand; the binary format will enclose all datafiles, bitmaps, models, ... whatever your program needs; and keep them in memory as much as possible if possible.
This will be the simplest way of doing it.
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
Do you really need to extract these files to disk. If you could extract them directly to memory and use the memory image, then people won't see the disk files.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Thanks for the replies so far.
There could be 100MB or even way more worth of files (though I will be recommending to users to keep their packed files to a limit of about 50MB to keep loading times sensible). I've never used memory files before, but I am guessing that if I store a lot of information there then it will impact on the game's performance... If I'm wrong, please tell me. Also, how would you run a game EXE in memory and tell it to access all of the game files it needs to work which are also in memory (and some that aren't)? (Given that I have no control over how the main game EXE works, as my launcher and packer is third-party...)
Many thanks for any suggestions,
KB
|
|
|
|
|
One thing you could do is save all the data files unprotected - but also unusable.
Perhaps the file headers are garbage - and your program inserts the correct data.
Are you concerned about people simply opening the supporting files with image or text viewers or are you trying to protect the files at the bit level?
|
|
|
|
|
If they are this big you would probably be better to encrypt the files so anyone looking at them sees garbage and then simply decrypt them when you load them into your app. This is simple and will solve 99% of your concern. There are a number of articles here on CP about encryption. Also look at Crypto++ www.cryptopp.com[^]
If you compress them as well you'll save some disk space. Hope that helps.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Hi, many thanks for your reply. The problem is that the program that needs to access the files is third party, so that couldn't read the encrypted files. My launcher would have to decrypt all of the files before they were extracted to disk in order for the third party app (game engine) to be able to use them, so the encryption would be pointless as the files would reside unprotected on disk so long as the game was running (as it may need to access any of the files at any point). If I am missing some major point here, sorry - please tell me and forgive me for being a clueless novice.
Thanks again,
KB
|
|
|
|
|
First off I beleive the executable will have to be a regular disk file. Outside of that you can use API hooking to intercept the ReadFile() CreateFile() and CloseHandle() functions and supply the data needed to the main program as if it was really reading files. This data could directly come from the disk by decompressing on the fly or by caching some of this data into a memory buffer.
[EDIT]
Here is a link to a discussion of API hooking:
http://www.codeproject.com/file/handles.asp?msg=571831&target=createfile%7Cwritefile#xx571831xx[^]
[/EDIT]
John
|
|
|
|
|
Hi,
Thanks again for the answers. Terry O'Nolley - I'm only trying to stop people from stealing the files and using them in their own applications, so your solution would be a good one if I do have to write all the files to disk. Thanks for the suggestion, I'll look into it if I can't work out the hooking...
John M. Drescher - thank you, this would be the perfect solution. I think this is what I've been trying to find out how to do, without actually knowing the name for it. Having the 3rd-party executable written to disk is no big deal, as this is of no use to any potential resource lifters, it's only the models, bitmaps etc that the EXE has to have access to that I want to protect. (And an added benefit of this method is that the game wouldn't require an extra 100-odd MB of diskspace to run.) If I understand you correctly, this is what my ideal API hook program would do:
-My launcher program extracts the 3rd party EXE to a temporary folder and runs it.
-My program then monitors the program that has been launched for as long as it runs.
-Whenever the other program tries to read a file from disk, my program intercepts the call, finds out which file is being requested, extracts it from the archive file, lets the program load it, and then deletes it...
(I figure the first stage is to write the file temporarily to disk and get that working before trying to cache it into a memory buffer.)
This is probably very ambitious for my limited coding ability, as I am working with the straight Windows API and still in the process of learning. However, I would like to attempt this. Thank you for the link. I am now trying to find out as much as possible about API hooks.
If anybody could give me any other pointers or good links (or even tell me about good books) that would help me write an API hook that could achieve all of this, I would be really grateful.
Thanks again for all the help, much appreciated.
Cheers,
KB
|
|
|
|
|
|
|
|
I have a solution doing proper system level protection that I have available which will allow protection of files and entire directories but there is a price to pay.
|
|
|
|
|
the #import directive is like this:
#import "D:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6EXT.OLB"
while compiling,errors generated as below:
Compiling...
temp.cpp
E:\emmai\temp\temp.cpp(8) : error C2772: #import referenced a type from a missing type library; '__missing_type__' used as a placeholder
e:\emmai\temp\debug\vbe6ext.tlh(212) : error C2146: syntax error : missing ';' before identifier 'CommandBars'
e:\emmai\temp\debug\vbe6ext.tlh(212) : error C2501: '__missing_type__' : missing storage-class or type specifiers
e:\emmai\temp\debug\vbe6ext.tlh(212) : error C2501: 'CommandBars' : missing storage-class or type specifiers
e:\emmai\temp\debug\vbe6ext.tlh(233) : error C2146: syntax error : missing ';' before identifier 'GetCommandBars'
e:\emmai\temp\debug\vbe6ext.tlh(233) : error C2501: '__missing_type__' : missing storage-class or type specifiers
e:\emmai\temp\debug\vbe6ext.tlh(255) : error C2061: syntax error : identifier '__missing_type__'
e:\emmai\temp\debug\vbe6ext.tli(32) : error C2143: syntax error : missing ';' before 'tag::id'
e:\emmai\temp\debug\vbe6ext.tli(32) : error C2433: '__missing_type__' : 'inline' not permitted on data declarations
e:\emmai\temp\debug\vbe6ext.tli(32) : error C2501: '__missing_type__' : missing storage-class or type specifiers
e:\emmai\temp\debug\vbe6ext.tli(32) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
temp.exe - 11 error(s), 0 warning(s)
I Love This Game!
|
|
|
|
|
Hi!
I get a ATL object by other object's method. like below
STDMETHODIMP CBanana::GetApple(IApple** apple)
{
CComObject<CApple>* p =NULL;
CComObject<CApple>::CreateInstance(&p);
p->QueryInterface(apple);
return S_OK;
}
But i dont know how to turn it back( from interface to real class). the code list below seems doesn't work.
STDMETHODIMP CBanana::DoSomethingOnApple(IApple* apple)
{
CApple* p = dynamic_cast<CApple*>(apple);
p->num = 3;
}
I think dynamic_cast can't be used in this situation. But i really don't know the proper way.
Would you please lend me a hand? I have blocked in this problem for almost one week.
|
|
|
|
|
You don't have to convert it back. If you look at the definition of CComObject<> you'll see:
template <class Base>
class CComObject : public Base
which means that CComObject<Base> inherits from Base . Everything Base has to offer, so will CComObject<Base> .
--
Serial killers don't kill their boyfriends.
|
|
|
|
|
I dont understand. I try to convert IApple into CApple or CComObject<capple>. Any idea?
|
|
|
|
|
Why do the conversion to IApple to begin with? It is possible, but very unsafe, see peterchens answer down below.
A rule of thumb is to convert to IApple's just before they leave a method defined in a COM interface.
--
You know me. I sure know you.. Everyone of you!
|
|
|
|
|
novachen wrote:
But i dont know how to turn it back( from interface to real class
Rule of thumb: You must not, because your apple might sit on a server in Siberia.
Long answer: Unless you know 100% that the class implementing IApple was created on the same machine, in the same process (a few registry entries could easily break that). One of the fundamentals of COM is that you can never assume anything about the Implementing class, only abotu the interfaces.
The bad thing is, it works most of the time, for inproc servers, so people try it.
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
Thanks!
But in fact, I try to hide a complex structure inside COM interface. On the interface of COM, Apple is a very simple object, but in the eyes of the other objects in the same COM dll, Apple has more content than the interface.
So i hope IApple can turn back into CApple, that i can access the hid part. I can't confirm the objects sit with client at same computer, but i can confirm those objects access each other on the same server.
How can i achieve this design?
|
|
|
|
|
You cam
1. Make Apple only creatable by Banana
2. Tag each Apple instance with a GUID, that can be queried through the IApple interface
3. Keep a map<GUID, CApple *> to retrieve the CApple * belonging to an IApple *
4. Reject each IApple you get that you don't know.
I have a slightly simpler case, that uses a slightly simpler implementation:
Noone passes an IApple back to me (I just hand it out), and the apple doesn't have any state that can't be dereived from Banana. So I let the Banana implement the methods of Apple and make the IApple implementation forward the calls to it's Banana. Some care with avoiding circular ref's is all to take care of.
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
Sorry if I waste some bytes on this forum now, but I can't
get this to work as i thought it would.. My questions are:
1) Why don't the DerivedList1 and DerivedList2 seem to
inherit the count() and the two get_instance()-methods?
For me, they don't pop up in under the classes in the
"Class view"-tab.
and...
2) ..what must I do to make them So maybe just an an-
swer to the first question will be enough.
Code goes here
-------------------------------------------
#ifndef MY_HFILE_H
#define MY_HFILE_H
#include <list>
using std::list;
#include <string>
using std::string;
class Class1;
class Class2;
template<class T>
class GenList : public list<T*> {
public:
virtual string to_string(Class1* receiveObj, bool check=true);
int count(string key);
bool get_instance(int nr, T* dest, int& instance_nr);
bool get_instance(string key, T* dest, int& instance_nr);
};
class DerivedList1 : public GenList<Class1> {
public:
string to_string(Class1* receiveObj, bool check=true);
};
class DerivedList2 : public GenList<Class2> {
public:
string to_string(Class1* receiveObj, bool check=true);
};
#endif // #ifndef MY_HFILE_H
-------------------------------------------
Thank you for any input on this
/P
|
|
|
|