Topic created on: October 16, 2007 05:17 CDT by ravinc30.
I am using OllyDbg to debug an application which read/write a number of files. Can anyone help me if it is possible to put breakpoint on CreateFileA/CreateFileW for a specific file name?
> ravinc30: I am using OllyDbg to debug an application which read/write a number of files. Can anyone help me if it is possible to put breakpoint on CreateFileA/CreateFileW for a specific file name?
you can use a conditional breakpoint and check for the filename on the stack.
if you set the bp in kernel32.dll you could use something like
STRING[[esp+4]] == "C:\\your\\filename.here"
for the condition.
additional conditions could be add with || operator, at least as far as I remember..
ollydbgs manual will help
I tried it. But may be I am not expert to use, it I do not understand it fully, can you please explain all inputs needed to fill in the box or if you can provide some screenshot.
> ravinc30: > > I tried it. But may be I am not expert to use, it I do not understand it fully, can you please explain all inputs needed to fill in the box or if you can provide some screenshot.
i dont know how to explain it better than what i already explained still i will attempt once again
find and go to CreateFileW api in kernel32.dll
easiest way is to hit ctrl+g (goto ) and type CreateFileW and hit ok
you should be somewhere near here
7C810976 kernel32.CreateFileW MOV EDI, EDI
or view -> executable modules -> select kernel32.dll--> right click -> view names -> scroll down in the new window and find CreateFileW
and double click on the line you should be in CreatFileW()
7C810976 kernel32.CreateFileW MOV EDI, EDI
with that line selected press shift key and f4 key at same time one after another (like you do ctrl+alt+delete )
shift +f4 should pop up a dialog
its heading should be
set conditional log breakpoint at kernel32.CreateFileW
if not stop and redo till you get this dialogbox with this heading
now you should see a condition edit box ignore it
in the next line you will see
explanation = expression (two edit boxes ) ignore explanation
in the expression edit box type [esp+4]
in the next line you should see decode value of expression as drop down box (a small arrow will be visible and you can click it and it will drop down a list that you can select and use)
it will have a default Assumed by Expression string already
clcik the arrow
point your mouse to Pointer to Unicode String and click it
you should see the decode box filled with Pointer to Unicode string
now below this there should be three radio buttons
leave the first radio button pause program at IN its default location never pause
change the second radio button (log value of exprresssion )to Always
you should notice the ok button will be enabled now which was grayed out by default
leave the third radio button in its default value never
hit ok
after you hit ok you should see a pink marker in the first line
7C810976 kernel32.CreateFileW MOV EDI, EDI ; ntdll.7C910738
if there is a pink marker than you have set a conditional breakpoint
you can do view -> breakpoints and confirm your breakpoint is set correctly or not (alt+b)
Breakpoints, item 1
Address=7C810976 kernel32.CreateFileW
Module=kernel32
Active=Log
Disassembly=MOV EDI, EDI
if it is there
do view log (alt +l)
right click --> log to file --> choose your path to the log file and your name of the log file (or leave it to default log.txt)
now you are all set
hit f9 (or run or step through or trace or animate or whatever )
when you are finished you can close the log file
view -> log (alt+l) --> right click -> close log file
Log data, item 0
Message=Log file closed
now you can read grep edit your log file
7C810976 COND: 0012EEAC "\\.\PIPE\lsarpc"
and when you have narrowed down some thing
you can use the shift +f4 again and set conditions change the pause program to on condition radio button and do all other things you fancy
and while replying please dont quote full reply
quote only relevent parts
and no i cant provide screenshot as i dont think this forum accepts image uploading to threads