Click here to Skip to main content
14,325,129 members

C / C++ / MFC

 
GeneralRe: Simple anti virus project (Argv FILE* dirent.h) Pin
a random user25-May-15 2:24
membera random user25-May-15 2:24 
GeneralRe: Simple anti virus project (Argv FILE* dirent.h) Pin
Richard MacCutchan25-May-15 2:33
protectorRichard MacCutchan25-May-15 2:33 
GeneralRe: Simple anti virus project (Argv FILE* dirent.h) Pin
a random user25-May-15 2:59
membera random user25-May-15 2:59 
GeneralRe: Simple anti virus project (Argv FILE* dirent.h) Pin
Richard MacCutchan25-May-15 3:25
protectorRichard MacCutchan25-May-15 3:25 
GeneralRe: Simple anti virus project (Argv FILE* dirent.h) Pin
a random user25-May-15 3:34
membera random user25-May-15 3:34 
QuestionC language Help using Dirent.h Pin
a random user22-May-15 6:24
membera random user22-May-15 6:24 
SuggestionRe: C language Help using Dirent.h Pin
Richard MacCutchan22-May-15 7:19
protectorRichard MacCutchan22-May-15 7:19 
AnswerRe: C language Help using Dirent.h Pin
k505422-May-15 7:37
memberk505422-May-15 7:37 
Looks to me like you're most of the way there. You probably want to read in your reference file into a buffer. You can use _stat() to get the file size for malloc().

Next, it depends on where the signatures are in the file. If they're at a known location you could use fseek(), fread() and memcmp() to determine if the signature is in the file or not. If the signatures are at a random location, I'd pull the entire file into a malloced buffer (_stat() again), and then search through the buffer. The simple way would be use memcmp() at locations 0 ... (current_file_size - reference_file_size), but there's more efficent ways of going about that. If you know that there's no null chars in the either file (unlikely), maybe strstr() is an option.

some notes on what you have so far:
sizes[0], and sizes[1] will not change over the while loop, so they could be computed before entering the loop.
strlen("\\") is 1, not 2
you not calling free(string) within the while loop, so you're leaking memory. If you use my suggestion about slurping the file into memory, don't forget to free() that buffer too.
GeneralRe: C language Help using Dirent.h Pin
a random user23-May-15 1:06
membera random user23-May-15 1:06 
GeneralRe: C language Help using Dirent.h Pin
Richard MacCutchan23-May-15 2:15
protectorRichard MacCutchan23-May-15 2:15 
GeneralRe: C language Help using Dirent.h Pin
a random user23-May-15 2:56
membera random user23-May-15 2:56 
GeneralRe: C language Help using Dirent.h Pin
Richard MacCutchan23-May-15 3:04
protectorRichard MacCutchan23-May-15 3:04 
GeneralRe: C language Help using Dirent.h Pin
a random user23-May-15 3:08
membera random user23-May-15 3:08 
GeneralRe: C language Help using Dirent.h Pin
a random user23-May-15 3:45
membera random user23-May-15 3:45 
GeneralRe: C language Help using Dirent.h Pin
Richard MacCutchan23-May-15 6:27
protectorRichard MacCutchan23-May-15 6:27 
QuestionRe: C language Help using Dirent.h Pin
a random user23-May-15 9:47
membera random user23-May-15 9:47 
AnswerRe: C language Help using Dirent.h Pin
Richard MacCutchan23-May-15 20:58
protectorRichard MacCutchan23-May-15 20:58 
GeneralRe: C language Help using Dirent.h Pin
a random user23-May-15 23:05
membera random user23-May-15 23:05 
GeneralRe: C language Help using Dirent.h Pin
a random user23-May-15 23:19
membera random user23-May-15 23:19 
GeneralRe: C language Help using Dirent.h Pin
a random user24-May-15 2:08
membera random user24-May-15 2:08 
GeneralRe: C language Help using Dirent.h Pin
Richard MacCutchan24-May-15 2:19
protectorRichard MacCutchan24-May-15 2:19 
GeneralRe: C language Help using Dirent.h Pin
a random user24-May-15 2:51
membera random user24-May-15 2:51 
GeneralRe: C language Help using Dirent.h Pin
Richard MacCutchan24-May-15 3:08
protectorRichard MacCutchan24-May-15 3:08 
GeneralRe: C language Help using Dirent.h Pin
a random user24-May-15 4:08
membera random user24-May-15 4:08 
GeneralRe: C language Help using Dirent.h Pin
a random user24-May-15 5:17
membera random user24-May-15 5:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.