flat assembler
Message board for the users of flat assembler.

Index > Windows > Problem with a patching tool

Author
Thread Post new topic Reply to topic
randomdude



Joined: 01 Jun 2012
Posts: 83
randomdude
hi

im writing a little tool for patching a binary file

the problem is that for patching it, i need to click the Patch button twice Shocked the first time i click Patch it says 'Successfully patched' but nothing is changed in the file, and the second time it patches it correctly

what can be wrong? Confused


Description:
Download
Filename: EnginePatcher.ASM
Filesize: 7.79 KB
Downloaded: 122 Time(s)

Post 02 Jun 2012, 11:09
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17269
Location: In your JS exploiting you and your system
revolution
You write the file to disk before you patch the memory area.
Code:
     invoke  WriteFile,eax,FileBuffer,[nSize],BytesWritten,0
     test    eax,eax
     jz      .patch_error
        invoke  SendMessage,[id_checkip],BM_GETCHECK,0,0
    cmp     eax,BST_CHECKED
     je      .patchipcheckbox
    mov     byte[FileBuffer+112166h],0ebh
       jmp     .patch_done
 .patchipcheckbox:
       mov     byte[FileBuffer+112166h],75h
        .patch_done:    
I suggest you modify the memory buffer first and then write the buffer to disk later.
Post 02 Jun 2012, 11:28
View user's profile Send private message Visit poster's website Reply with quote
randomdude



Joined: 01 Jun 2012
Posts: 83
randomdude
oh lol what a stupid mistake i did Embarassed

thanks for the fast reply

Code:
.btn_patch:
        invoke  SendMessage,[id_checkip],BM_GETCHECK,0,0
        cmp     eax,BST_CHECKED
        je      .patchipcheckbox
        mov     byte[FileBuffer+112166h],0ebh
        jmp     .patchfile
        .patchipcheckbox:
        mov     byte[FileBuffer+112166h],75h
.patchfile:
        invoke  CreateFile,FileName,GENERIC_WRITE,0,0,4,FILE_ATTRIBUTE_NORMAL,0
        test    eax,eax
        jz      .patch_error
        invoke  WriteFile,eax,FileBuffer,[nSize],BytesWritten,0
        test    eax,eax
        jz      .patch_error
        invoke  MessageBox,0,patched,patchedcap,MB_ICONINFORMATION+MB_OK
        jmp     .closehandle
        .patch_error:
        invoke  MessageBox,0,patcherror,errorcap,MB_ICONERROR+MB_OK
        jmp     .closehandle   
    


its working fine now, thanks
Post 02 Jun 2012, 11:40
View user's profile Send private message Reply with quote
Fixit



Joined: 22 Nov 2012
Posts: 161
Fixit
I like your code and would like to use it with Masm.

I can convert most of the code but not all.

Could you help me ?

Thanks.
Post 12 Dec 2012, 00:52
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
I hate intertwining GUI calls with their counterparts like this:

Code:
if(!createFIle(...))
   MessageBox(...)
else if(!xxxFile(...))
  closeFile(...);
  MessageBox(...)
    


Just make a fucking function that does everything

Code:
str_error = "";
function doWork(params)
{
   if !CreateFile,...
       str_error = "failed to open file"; 
       return -1;
   ... etc
   return status_code;
}

; then

if(!doWork())
{
  MessageBox(0,str_errror,...)
}
    


Clear and concise.
Post 19 Jul 2014, 18:09
View user's profile Send private message Reply with quote
questlima



Joined: 27 Aug 2014
Posts: 37
questlima
typedef wrote:
I hate intertwining GUI calls with their counterparts like this:

Code:
if(!createFIle(...))
   MessageBox(...)
else if(!xxxFile(...))
  closeFile(...);
  MessageBox(...)
    


Just make a fucking function that does everything

Code:
str_error = "";
function doWork(params)
{
   if !CreateFile,...
       str_error = "failed to open file"; 
       return -1;
   ... etc
   return status_code;
}

; then

if(!doWork())
{
  MessageBox(0,str_errror,...)
}
    


Clear and concise.


now i get to learn how to write to patch programs:LOL with FASM and yes i always uses if else statement this is great stuff, i have learned how to
write that special *f... function*:LOL neatly thanks guys

_________________
Linux command are not what you intended to
learn but your were forced to learn it, without it
you will be like a sitting duck on your beautiful newly installed Linux desktop:)
Post 27 Aug 2014, 14:56
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.