|
Can't you instead generate an MD5 hash code from the exe and check that against a valid value to see if the exe was replaced or not?
Anyways, a little googling brought me to this[^], i guess you can go on from there...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
modified on Friday, October 15, 2010 4:20 PM
|
|
|
|
|
Thank you for your link. I think this will solve my problem. I will take a closer look.
|
|
|
|
|
Yourwelcome.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world.
Fry: But this is HDTV. It's got better resolution than the real world <
|
|
|
|
|
I have "abcdefghigklmnop" and I want to insert "123456789" after 'd' for example. How can I do it?
|
|
|
|
|
Create a new array and copy the three pieces into it in the required order. A few simple strXXX functions should do the job.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
I know this, but which functions is the question
|
|
|
|
|
if (laziness > selfEsteem) failAtEverything();
|
|
|
|
|
Take a look here[^] to get you started; you should get used to using MSDN if you wish to develop your skills in Windows programming.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Hi everyone, I have a program that reads ID3 tag information from mp3 file which is working. For ID3v1 tags, the track title starts at the 4th byte after the address of the TAG.
For some files I have encountered, the address where I expect the track title begins with the ASCII character code 0x20 which is a space, and there could be more of the spaces followed by the text. String copying becomes successfull only that the string begins with spaces and there is no problem.
Now the problem is that some of the mp3 files have spaces at the address where I expect the track title followed by garbage. I used a hex editor to view the bytes and I saw that the spaces were followed by garbage. This to me means there is no track title.
I want to know how I can detect this to avoid showing this garbage as the track title, or any other text I want since string copying uses the '\0' character to determine the end of the string. I used 'strncpy()' function in copying text.
|
|
|
|
|
I read about the ID3 tag format here[^], it says Strings are either space- or zero-padded. Unset string entries are filled using an empty string. , i guess this explains the space(s). However, it says that unset strings should be empty. So i guess when you see garbage it's either in a different encoding (no idea, like japanese characters or something), or the creator of the ID3 simply didn't bother following the specifications. If this later is the case, i doubt there is much you can do. Does any other player show the garbage also?
Could it be that the file contains more versions (or a different verision) of ID3 or has an extended tag ("TAG+") and only the "newest" tag contains the actual information and the rest is just "placeholder" with garbage?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
modified on Friday, October 15, 2010 11:28 AM
|
|
|
|
|
I checked again with a hex editor. The file contains 'TAG' beginning at the last 128 bytes. I am considering checking about 2 or 3 bytes where I expect the text and if they are all spaces, then I assume there is no text for what I was looking for. On Windows XP which I am using, viewing the summary properties of the file does not show the text for the track title which, viewing with a hex editor, begins with some spaces before some strange characters. That's why I want to try this approach. But I wish there is a better approach than this.
|
|
|
|
|
Can't a space (or zero character) at the very first position of the title mean it is empty? From your original post i gathered that sometimes there are spaces before the title but am not sure anymore. Is it possible that even when you see this case, i mean a space and then a title, that the title is actually just something that was in memory at the time the ID3 tag was written but because it starts with space it means that the rest of the string shouldn't be considered valid?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
Code-o-mat wrote: From your original post i gathered that sometimes there are spaces before the title but am not sure anymore.
I even wondered about this, but I have realised that once the beginning bytes are set to spaces, they are unset. But the problem was that I used strlen() to get the length of the text for the track title.
Meanwhile, this function uses the '\0' character to detect when to stop counting and therefore counted spaces as well. Then I called strncpy() to copy string of text of the number returned by strlen(). This was causing those garbage to be copied as well.
I have written my own function that returns the length of a string, and I wrote it such that it will used both the '\0' and the ' ' (space) characters to detect when to stop counting. Thanks for your guidance, I really appreciate it.
|
|
|
|
|
Based on the Wiki page I thought that in the header all the strings have fixed sizes, can't remember now for the title, e.g. 30 characters. If it contains a shorter string, the rest is padded with zeroes or spaces. So e.g:
[TitleString ]
In this case, reading the string till the first space will get you the title correctly, "TitleString", as much as i understand what you did now is "reading" the string until you find a space or a zero. However, if the title is this:
[Title String ]
then you will get "Title" only, althorough "String" belonds there too, right? I think what you can do here is checking the very first character, if it is zero or space, the title is not set, if it is not, then read all 30 characters and then trim away the ending spaces if any. Also, in the following case:
[ThisIsALongTitleWithLotsaChars]
then when you are looking for the "ending space/zero", you will just skip over the string and read into whatever comes after it, since no spaces or zeroes are in the string. The specs doesn't say the strings are terminated with anything.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Leela: Fry, you're wasting your life sitting
in front of that TV. You need to get out and see the real world.
Fry: But this is HDTV. It's got better resolution than the real world <
|
|
|
|
|
Hello All,
I am always confused between static, dynamic, and reinterpret casting. I tried to find answers but somehow they all are confusing... Could anyone clears this concept.
Thanks.
|
|
|
|
|
|
Cool, Thanks... I'm checking
|
|
|
|
|
static_cast and reinterpret_cast work in the same way than the classic C-style cast, but they are used in two different context:
static_cast is used when casting between two related types, for instance from a numeric type to another. The conversion could generate a loss of data, but without the cast operator the code compile; the compiler could generate a warning.
char a, b;
int x = 123;
double y = 123.456;
a = static_cast<char>(x); b = static_cast<char>(y); reinpterpret_cast is used when casting between two unrelated types, usually pointers, for instance from a pointer to a struct to a pointer to char . Without the cast operator the code doesn't compile; the compiler generate an error.
POINT pt = { 10, 21 };
unsigned char *pb = reinterpret_cast<unsigned char *>(&pt);
for(int i = 0; i < sizeof(POINT); i++)
printf("%02X ", pb[i]);
Finally, dynamic_cast is a polymorphic cast operator; it's used only with pointers, and its main property is that if the conversion is possible it return the pointer value, otherwise it returns NULL . It's useful when working with inheritance.
|
|
|
|
|
Intend to capture data from network with huge volume. I intend to use multi-treading tech to do it.
1. producer:capture thread for data capturing. capture data in one loop and put incoming data into buffer
2. consumer:worker thread.get data from the producer and do more data processing.
here the producer shares buffers with consumers.I want to use 2 buffers to get a high performance. and the two buffers works in ping-pang mode like this ...
// the two buffers for sharing data
BUFFER bufferA;
BUFFER bufferB;
one scenario is ...producer put data into bufferA and the consumer read data from bufferB.
the producer use the buffer in procedure ...
write data...
bufferA---bufferB----bufferA----bufferB.... in ping-pang mode.
the consumer use the buffer in procedure....
read data...
bufferB---bufferA---bufferB---bufferA.....in ping-pang mode.
of course, the synchronizition is the biggest problem here. That's my question too.
How to implement the synchronization by using CRITICAL_SECTION/EVENT or other kernal objects to get a highest performance?
Appreciated for you any input here ...
Sam/BR.
The world is fine.
|
|
|
|
|
I don't see any benefit in using two buffers instead of one.
As about synchronization, see "Synchronization Objects" at MSDN (I would use a mutex).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: I would use a mutex
Of all the things why a mutex? It's heavier than a critical section, and we're not even operating across process boundaries here!
There are some really weird people on this planet - MIM.
|
|
|
|
|
Because, for instance
Event, mutex, and semaphore objects can also be used in a single-process application, but critical section objects provide a slightly faster, more efficient mechanism for mutual-exclusion synchronization doens't look to me a good counterpart to the scaring
Starting with Windows Server 2003 with Service Pack 1 (SP1), threads waiting on a critical section do not acquire the critical section on a first-come, first-serve basis. This change increases performance significantly for most code. However, some applications depend on first-in, first-out (FIFO) ordering and may perform poorly or not at all on current versions of Windows
("Critical Section Objects" at MSDN ).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Man! You're in a mood to argue.
CPallini wrote: slightly faste
Only "slightly" faster, but put it in the context of execution - say thousands of times each seconds. That would make difference, especially in tight situations.
CPallini wrote: However, some applications depend on first-in, first-out (FIFO) ordering and may perform poorly or not at all on current versions of Windows
But then we're talking about reading data from sockets here - they aren't dependent on FIFO ordering. In fact, if an application is dependent on FIFO ordered execution, then that shouldn't worry far too much about performance. Because there's always a chance of having a 'pig' thread in between which would be slow, thereby rendering the whole process slow.
There are some really weird people on this planet - MIM.
|
|
|
|
|
Normally, I prefer CRITICAL_SECTION to do the sychronization. It's faster and easy to use. Exactly as Rajesh said, if no FIFO orderging requirement, critical section is a good choice internal process.
The world is fine.
|
|
|
|
|
I don't really get why you want to use two buffers for that. The two threads will work at different "speeds" so you won't have any control about which buffer is read or written. Why don't you simply use one buffer here ? The producer puts the data in one of the buffer (entering a critical section) and then signal an event that data is available. The consumer waits on the event to be signaled and then read data from the buffer (entering the critical section).
|
|
|
|