ragdog Posted January 19, 2008 Posted January 19, 2008 hi guysi coding a patchengine.How is it useful to compare 2 files whether they are equal? With a crc32 for original and patched file? And then I have a question, there are some examples for patchengines in masm32greetsragdog
Loki Posted January 19, 2008 Posted January 19, 2008 How is it useful to compare 2 files whether they are equal? With a crc32 for original and patched file? Depends what you are trying to accomplish. Are you trying to simply prove that two files are the same/different, or are you trying to show where they differ? If the former then a simple CRC/MD5 will do the trick, otherwise something more complex to report the differing bytes will be required.
ragdog Posted January 19, 2008 Author Posted January 19, 2008 (edited) I have a routine to compare the different of original and patched files was also works but if the files are equal, I would like a message no differentssry for my bad english Edited January 19, 2008 by ragdog
ragdog Posted January 19, 2008 Author Posted January 19, 2008 (edited) invoke SetFilePointer,hPatchFile,0,0,FILE_END xor edi,ediNextByte: invoke ReadFile,hCrkFile,addr bRead,1,addr brw,0 jz EOF mov al,byte ptr [esi+edi] mov ah,byte ptr [bRead] cmp al,ah jnz @Add@@: inc edi mov hOffsets,edi dec ebx jnz NextByte jmp EOF@Add: movzx eax,byte ptr [bRead] mov hCrkBytes,eax movzx eax,byte ptr [esi+edi] mov hOrgBytes,eax invoke WriteFile, hPatchFile, addr hCrkBytes, 1, ADDR brw, 0 invoke WriteFile, hPatchFile, addr hOffsets, 4, ADDR brw, 0 jmp @B EOF: invoke MessageBox,hWnd,addr szPatchCreated,addr szCaption,MB_OK invoke UnmapViewOfFile,esi This is my routine to compare the bytes of original and patched files! I would also like to incorporate a function of the files on examining whether the files are equal if so (no differents found)And because my question was now whether I advance crc32 check should include the 2 files reviewed whether the same isthanks for you repleyragdog Edited January 19, 2008 by ragdog
Loki Posted January 19, 2008 Posted January 19, 2008 Ok, I'm still struggling as I still dont know what you're asking.Your code compares 2 files.... fine. If one is patched and one is original, why are you wanting to CRC them? Or is you question "what benefit would crcing them have after this process?".Sorry, maybe I'm being dumb but you'll have to find a way to be a little clearer. Are you german? There are a few german speakers here so on this occasion if you post your query in german, perhaps someone else will be able to help you better than I can (in general though please continue to use english on this board).
ragdog Posted January 19, 2008 Author Posted January 19, 2008 (edited) hmmBoth files are equal (no differents bytes found) as messagesbox I have a routine 2 files compares the original and patchedNow I want to reach if both files are the same one comes messagesbox (noDifferences found). It would be better to check with a crc32 to solve before the routine is called Edited January 20, 2008 by ragdog
Ufo-Pu55y Posted January 19, 2008 Posted January 19, 2008 It would be better to check with a crc32 to solve before the routine is calledI don't see any reason for a crc check.And it wouldn't be faster anyway ?
ragdog Posted January 19, 2008 Author Posted January 19, 2008 No idea about, I ask you Would you this function (if equals) not used?
Ufo-Pu55y Posted January 19, 2008 Posted January 19, 2008 No idea about, I ask you Would you this function (if equals) not used? No! Coz even for a crc check you would need to read the whole file !Somebody should correct me, but the crc check of 2 files should definitely be slower than just comparing them.
ragdog Posted January 19, 2008 Author Posted January 19, 2008 (edited) How would you solve this problem Or would you (if equal) not used? Edited January 19, 2008 by ragdog
Ufo-Pu55y Posted January 19, 2008 Posted January 19, 2008 You do NOT need crc for comparing files ! oO
ragdog Posted January 19, 2008 Author Posted January 19, 2008 (edited) I have it resolved It is correct?? .datahWrCheck dd 1.code...... invoke WriteFile, hPatchFile, addr hOffsets, 4, ADDR brw, 0 mov hWrCheck ,0 jmp @B EOF: cmp hWrCheck, 1 jnz @F invoke MessageBox,hWnd, addr szItssame,addr szCaption,MB_OK invoke CloseHandle,hPatchFile invoke DeleteFile,ADDR szFile jmp @end@@: invoke MessageBox,hWnd,addr szPatchCreated,addr szCaption,MB_OK @end: Edited January 19, 2008 by ragdog
Loki Posted January 20, 2008 Posted January 20, 2008 Still no idea what you're asking so dont know if its resolved. I thinking you need to go and read about CRC and decide for yourself if you need it or not.From what I can make out though I agree with UFO - you dont need it.
ragdog Posted January 20, 2008 Author Posted January 20, 2008 thanks I have solved without crc32 invoke WriteFile, hPatchFile, addr hModBytes,1,addr BytesWrite, 0 invoke WriteFile, hPatchFile, addr hOffsets,4,addr BytesWrite, 0 jmp @B EOF: cmp BytesWrite,0 jnz @F invoke MessageBox,hWnd,CTEXT("No differences founds!"),CTEXT("Information"),MB_OKgreetsragdog
Loki Posted January 20, 2008 Posted January 20, 2008 Good stuff... sorry I couldn't be of more help initially.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now