Jump to content
Tuts 4 You

Patchmaker


ragdog

Recommended Posts

Posted

hi guys

i 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 masm32

greets

ragdog

Posted
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.

:)

Posted (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 differents

sry for my bad english

Edited by ragdog
Posted

I dont see your issue/question?

Posted (edited)
		invoke SetFilePointer,hPatchFile,0,0,FILE_END
xor edi,edi
NextByte:
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 is

thanks for you repley

ragdog

Edited by ragdog
Posted

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).

Posted (edited)

hmm

Both files are equal (no differents bytes found) as messagesbox

I have a routine 2 files compares the original and patched

Now I want to reach if both files are the same one comes messagesbox (no

Differences found). It would be better to check with a crc32 to solve before the routine is called

Edited by ragdog
Posted
It would be better to check with a crc32 to solve before the routine is called
I don't see any reason for a crc check.

And it wouldn't be faster anyway ?

Posted

No idea about, I ask you :(

Would you this function (if equals) not used?

Posted
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.

Posted (edited)

How would you solve this problem

Or would you (if equal) not used?

Edited by ragdog
Posted

You do NOT need crc for comparing files ! oO

Posted (edited)

I have it resolved :unsure:

It is correct??

.data
hWrCheck 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 by ragdog
Posted

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.

Posted

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_OK

greets

ragdog

Posted

Good stuff... sorry I couldn't be of more help initially.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...