|
References are not nessecairily better then pointers, it just depends on what you want to do! Using a pointer gives you the option to pass NULL (or use it as a default parameter)! On the other hand, when you don't want to change the contents of the object (making it constant) it's a lot easier with a reference!
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
Thanks for your reply. I agree with you in that its use is much more obvious. Also, the ability to pass NULL in pointers would have uses somewhere.
I have heard one of my friends saying that references take two bytes in memory, whereas pointers take four. Is this true? And if it is, would this allow for faster processing?
Thank you for your time.
Hosam Aly Mahmoud
|
|
|
|
|
Hosam Aly Mahmoud wrote:
I have heard one of my friends saying that references take two bytes in memory, whereas pointers take four. Is this true?
No. References take the same amount of memory as pointers.
References are generally safer than pointers because they are gauranteed to point to something, and they are type-safe (they can't be cast to references of incompatible types).
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"
|
|
|
|
|
What can I say? Thank you again Ryan!
Hosam Aly Mahmoud
|
|
|
|
|
You're welcome
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"
|
|
|
|
|
Your welcome
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
I have a report (and a partial fix) from one of the guys who helps out on my VCF project, that when using EM_SETSEL/EM_GETSEL message, multiple lines broken by \r\n do not get handled correctly. Apparently the \r characters are not taken into consideration and the selection is screwed up. Has anyone else run into this? Is there a simple solution to handling this?
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
|
|
|
|
|
I met this problem, and my solution is that I assumed there is no \r in the string, when processing EM_GETSEL message, but if I need \r, I can get string by invoking CEdit::GetWindowText(CString).
|
|
|
|
|
Jim Crafton wrote:
...multiple lines broken by \r\n do not get handled correctly. Apparently the \r characters are not taken into consideration and the selection is screwed up.
Which means what exactly? I've not yet seen the \r\n pair cause unknown problems.
|
|
|
|
|
Hi everyone. I have a problem concerning vectors. I have a function in which I fill a vector of an object with data. This object consists of char*, long etc variables and a number of set and get methods for setting and retrieving the data. The function returns the vector. Inside the vector I see the data correctly by printing them, but with the returning vector I cannot see them correctly.
As parameters to the object (the set methods) I pass CString objects which I convert to char* with (char*)(LPCTSTR)variable.
Does anyone know what is wrong?
When I call the method I assign the returning vector into a new one which I construct at the time of the function call as: vector<object> e = class_object.method(); and then navigate through the vector.
|
|
|
|
|
i know that question was posted some weeks ago or so... but i didn't find it anymore
i want to code a module, which is able to load a dll with a exported c++ class!
how to do that?
GetProcAddress wouldn't make any sense, because of the c++ names, and how do i set the addresses of class member functions?
any suggestions?
thx
Don't try it, just do it!
|
|
|
|
|
|
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
|
|
|
|
|
|