|
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
|
|
|
|
|
petter_e wrote:
Why don't the DerivedList1 and DerivedList2 seem to
inherit the count() and the two get_instance()-methods?
They do.
petter_e wrote:
For me, they don't pop up in under the classes in the
"Class view"-tab.
That's because they are actually members of the base class.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
> That's because they are actually members of the base class.
Yes, but they should still show up! My bet is on a intellisense/template bug.
--
Serial killers don't kill their boyfriends.
|
|
|
|
|
Jörgen Sigvardsson wrote:
Yes, but they should still show up! My bet is on a intellisense/template bug.
Aaah. He's not talking about intellisense. He's talking about ClassView . Inherited functions don't appear there, but, as you said, should appear in the intellisense window.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Thank you for your entries!
Meanwhile, i have struggled with this stuff (somehow
it felt familiar in a worrying way).
My real problem with this wouldn't be wether the methods
showed up or not, it was merely a symptom in line with was
bothering me: I could not _access_ the methods either (from
the DerivedLists) - maybe I should have mentioned that, too.
What I was doing was of course that I 1st hadn't defined the
functions, so I wasn't worried about not being able to use them
at that point. I just wrote them BUT! (moan) I placed them in a
.cpp-file of their own. So they weren't visible or what the
term is (and still not showing in the Class view), and I just
got complaints of unresolved externals for them when linking.
It was a year ago (but under some command line compiler) I did
battle a while with some template things and for the 1st time
realized I should place the template class' member functions
in the same file. This was my 2nd revelation. Hope I need no 3rd
Thanks again for your input!
Regards
/Petter
|
|
|
|
|
Hi everyone. I have an MFC app which usesDAO to access Jet/Access databases. The development machine is Win2000 sp3 with Visual Studio 6 installed. The app is statically linked so MFC DLL version conflicts shouldn't be an isue. The app works 100% of my development machine, but I tried it on a Win98se machine and it won't open a Jet database file. The Win98se machine has DCOM98 and MDAC 2.5 installed on it, and only necessary software installed. Only my app is running whne I tested it. The app runs fine until I attempt to open a database. The code below is how I open the database
<br />
CDaoDatabase* db;<br />
CEDaoRecordset* rs;<br />
CString strSQL;<br />
long int lTemp;<br />
<br />
try<br />
{<br />
db = new CDaoDatabase();<br />
db->Open(strDBPath, FALSE, TRUE, _T(";PWD="));<br />
rs = new CEDaoRecordset(db);<br />
<br />
strDBPath is the path to the DB Jet database file, which is known to be valid, and not read-only.
Once it hits db->Open() I get an "unknown exception" error and the program closes.
I know it could be anything, but does anyone have any ideas as to what could cause this? Did I forget to install something? The app is MBCS based, not unicode.
|
|
|
|
|
Have you caught the exception and analyzed it? You should be able to get detailed error information if you use try{}catch{} and take a look at the error codes being returned.
Are you 100% sure that the database itself was copied over exactly? If both machines are trying to access the same DB, then you may want to look at the DB driver versions installed on each machine. Your development platform may be using different drivers.
|
|
|
|
|
I am making a small Win32 API application. I wanted to have a coloured background. When I tried to handle WM_ERASEBKGND, I got too much flicker. I tried to make a memory dc and use it, but that did not improve the flicker. Is it something I do wrong? Could you please show me how to handle WM_ERASEBKGND without flicker?
Note: I noticed that the flicker was gone when I created a brush and made myWndClass.hbrBackground point to it. But the problem is that I may want to draw in WM_ERASEBKGND, not just have a single brush.
<marquee behavior="alternate">Hosam Aly Mahmoud
|
|
|
|
|
Do everything in response to WM_PAINT and use a memory DC. Handle WM_ERASEBKGND and do nothing there.
Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Thank you for your reply. I thought that WM_PAINT would only allow me to draw a certain region of the window, not all of it. Also, the docs said that to make a background (for example a picture) you should handle WM_ERASEBKGND. Am I wrong?
<marquee behavior="alternate">Hosam Aly Mahmoud
|
|
|
|