Re: [Dev-C++] New to the list, and a quick question
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Per W. <pw...@ia...> - 2007-01-05 19:53:56
|
Actually, C++ is a high-level language too even if some have claimed the
precursor language C to be "high-level assembly" :)
Yes, it is possible to store binary data within the application. It can
bedone in a number of ways.
One common way is to use a little utility application that takes the
binary resource and converts to an array of hex data that is then compiled
into the binary like:
-----
// sound_cannonshot.cpp
unsigned char wavesound_cannonshot[] = {
0x10,0x20,0x30,...
};
unsigned wavesound_size = sizeof(wavesound_cannonshot);
-----
Another approach is to store the sound as a binary resource, the same way
that Windows applications stores icons and bitmaps.
If using the resource file, then it is very easy to extract the data using
an resource editor on your executable. Even if the resource file is
compiled, the resource editor will display a list of all items in the file
- what type they are and what identifier to access them.
If storing the sound in the source, a normal tool can not extract it.
However, writing a tiny app that just feeds the full exe file through the
sound card may probably play the sound, unless the sound was incorrectly
aligned, i.e. the low byte of one 16-bit sample got played together with
the high byte of the next 16-bit sample, in which case it would probably
just sound like noise.
If it is every more important to protect the data, you can combine any of
the above methods - or the use of external sound files - with encryption.
Load file, decrypt, play. The openssl project contains readily available
code to encrypt/decrypt streams of data using government-approved
algorithms.
Alas, even with encryption, you will only be able to protect unmixed raw
sounds. The actual output to the sound card can normally alwasy be
retrieved, since the Windows sound system have a lot of layers where
third-party filters may install and rip the data.
/Per W
On Fri, 5 Jan 2007, Philip Bennefall wrote:
>
> Hello everyone.
>
> My name is Philip Bennefall, I am an audio producer and game programmer
> from Sweden. I am just getting into C++, before now I've been working
> with high level languages. But lately I've started to feel that they
> simply are not good enough for my needs, they limit me too much in what
> I can do. I'm a complete beginner at the actual C++ language, although I
> know programming well. My first question is, in Dev C++, is it possible
> to pack for example a sound file into your executable and then access it
> directly from memory inside of the application? That is, without ever
> extracting it on to the users harddrive. That way, noone will be able to
> see the file unless they know how to disassemble executables which is
> certainly beyond me. Basically I just want to put the file in the
> executable together with my code and be able to access it directly with
> a memory address or perhaps a buffer pointer.
>
> If anyone can answer this, I'd be very glad.
>
> Thanks in advance.
>
> Regards
> Philip Bennefall
|