-
a program which repeats users action
hello all .
i need to make a program which when runs repeats what the user inputs .
by saying repeating the user input , i mean getting the Keystroke the user inputs and then repeating that Keystroke . (so that any action initiated by that keystroke , re-initiate again )
how should i go about it ?
what steps and APIs are needed to achieve such task ?
Thanks in advance
-
Re: a program which repeats users action
This time I'll ask first... ;) What platform is this supposed to run on?
-
Re: a program which repeats users action
-
Re: a program which repeats users action
Ok, then if it is planned to be a console app it seems logical that it doesn't record and play back the keystrokes it receives itself, otherwise it would also need to define the "action initiated by that keystroke" itself, right? And you didn't say any word about what they might be so I don't think that's the case.
If, OTOH, you're planning a GUI app, I don't think it makes a big difference whether your app is supposed to record/play back its own keystrokes or those of other apps: In both cases you would probably need some sort of hooking, at least if you want to implement it in a half-way generic manner. Unfortunately, this is an area of Windows programing on which I don't have the slightest experience... :o
At any rate, it would involve some amount of Windows API and using that basically doesn't differ between assembly language and C++. Therefore I would suggest to post an inquiry in the C++ and Win API section (that is more frequented than the one here) in order to first put up a solution in C or C++ and then translate that to assembly language. (You know, C++, don't you?)
BTW, I always wonder why people want to write something like that in assembly language. It's much more effort without the slightest effective gain in performance. Is this an assignment?
-
Re: a program which repeats users action
Quote:
Originally Posted by
Eri523
Ok, then if it is planned to be a console app it seems logical that it doesn't record and play back the keystrokes it receives itself, otherwise it would also need to define the "action initiated by that keystroke" itself, right? And you didn't say any word about what they might be so I don't think that's the case.
If, OTOH, you're planning a GUI app, I don't think it makes a big difference whether your app is supposed to record/play back its own keystrokes or those of other apps: In both cases you would probably need some sort of hooking, at least if you want to implement it in a half-way generic manner. Unfortunately, this is an area of Windows programing on which I don't have the slightest experience... :o
At any rate, it would involve some amount of Windows API and using that basically doesn't differ between assembly language and C++. Therefore I would suggest to post an inquiry in the
C++ and Win API section (that is more frequented than the one here) in order to first put up a solution in C or C++ and then translate that to assembly language. (You know, C++, don't you?)
BTW, I always wonder why people want to write something like that in assembly language. It's much more effort without the slightest effective gain in performance. Is this an assignment?
thanks .
the program must be resident in memory , no GUI, nothin, sth like windows service which has no GUI but is running at background doing its jobs :) .
yeah i know C++ :) .
I agree with you , this is my little brothers final project in assembly course and the prof told them to bring him such a thing in assembly!
so he asked for my help and thats im here to find all i can and help him out on his project :)
-
Re: a program which repeats users action
Quote:
Originally Posted by
Master.
the program must be resident in memory , no GUI, nothin, sth like windows service which has no GUI but is running at background doing its jobs :) .
That entire "resident in memory" concept is a remnant from the days of DOS (you know when they were, don't you? ;)) and nowadays completely antiquated. Now that all sorts of processes are concurrently running under Windows it doesn't make any sense any more at all. The concept that probably comes closest to that under Windows is the hooking that I mentioned already.
Quote:
yeah i know C++ :) .
That helps a lot! :thumb:
Quote:
I agree with you , this is my little brothers final project in assembly course and the prof told them to bring him such a thing in assembly!
so he asked for my help and thats im here to find all i can and help him out on his project :)
Well, honestly, that prof seems to be an alien from a planet (or alternate universe) where high-level languages and modern OSes not yet have been invented... :sick:
-
Re: a program which repeats users action
Quote:
Originally Posted by
Eri523
That entire "resident in memory" concept is a remnant from the days of DOS (you know when they were, don't you? ;)) and nowadays completely antiquated. Now that all sorts of processes are concurrently running under Windows it doesn't make any sense any more at all. The concept that probably comes closest to that under Windows is the hooking that I mentioned already.
That helps a lot! :thumb:
Well, honestly, that prof seems to be an alien from a planet (or alternate universe) where high-level languages and modern OSes not yet have been invented... :sick:
lol man , :))
your last paragraph made me lol for real :))
sure thing .
anyway, the c++ section seems to be of no use ( so far) .
im currently playing with Iczelions tuts on windows hooks . (git 24 hours left :cry: )lets see if i can make it :sick:
-
1 Attachment(s)
Re: a program which repeats users action
Ok . i've got my hands on an assembly sample .
but i had no luck in compiling this kind of app !! any help is greatly appreciated .
(reading the windows assembly tuts on compiling and linking procedures i found out that for compiling : i should :
Code:
ml /c /coff /Cp myapp.asm
and then for linking :
Code:
link /SUBSYSTEM:WINDOWS /LIBPATH:c:\masm32\lib myapp.obj
how ever this one wont work for the sample i downloaded .
( i could only build a simple windows assembly sample with this method! ( actually it was only a messagebox!)
i attached the sample . i would greatly appreciate if some one help me build this sample , so that i can work on it :)
and by the way if there is a need for masm , you can download one from here :
http://www.masm32.com/
Thanks in advance
-
Re: a program which repeats users action
Quote:
Originally Posted by
Master.
(git 24 hours left :cry: )lets see if i can make it :sick:
Apparently these 24 hours are over now but it looks like you're still interested in this subject.
I downloaded your sample file and had a brief look at the source files. I didn't see anything obviously wrong. The command lines you use for compiling and linking look ok too. I couldn't do more for now because I'm a bit in a hurry, but I'll pick that up later (unless I find a message from you saying you don't need that anymore.)
Quote:
Originally Posted by
Master.
how ever this one wont work for the sample i downloaded .
Could you please define "won't work"? Compilation error? Linker error? Runtime error? Runtime crash?
BTW, it is generally helpful to describe the problem as preceisely as possible when asking others for help... ;)
-
Re: a program which repeats users action
Quote:
Originally Posted by
Eri523
Apparently these 24 hours are over now but it looks like you're still interested in this subject.
I downloaded your sample file and had a brief look at the source files. I didn't see anything obviously wrong. The command lines you use for compiling and linking look ok too. I couldn't do more for now because I'm a bit in a hurry, but I'll pick that up later (unless I find a message from you saying you don't need that anymore.)
Could you please define "won't work"? Compilation error? Linker error? Runtime error? Runtime crash?
BTW, it is generally helpful to describe the problem as preceisely as possible when asking others for help... ;)
Thanks Eri523 :).
actually i get no error at all :sick:! the executable gets built , but the catch is it is not either executable nor does it have any ICON!! it seems as if it is a console application! 5KB! and nothing happens!
i think because this sample has a library , ICON and a resource file , the compilation procedure differs a bit!
and about that 24 hour ( i got another 12 hours :) )
-
Re: a program which repeats users action
-
Re: a program which repeats users action
I have not forgotten you and your problem. Sorry, though, that I couldn't yet get back to you. I'm busier than expected at the moment (and actually a significant part of that is CodeGuru-related.) Unfortunately, thoroughly checking your assembly code is nothing I can simply do en passant.
But there's specifically one thing you can do right now to help me with my analysis in advance: Did I understand your scenario right that your program is meant to be a Windows GUI app, just without any (visible) GUI? Or, in particular, no Windows console app?
Counting from the time stamp of your post #10, your additional 12 hours seem to be over now too. :( I hope all our efforts still are not completely in vain...
-
Re: a program which repeats users action
Quote:
Originally Posted by
Eri523
I have not forgotten you and your problem. Sorry, though, that I couldn't yet get back to you. I'm busier than expected at the moment (and actually a significant part of that is CodeGuru-related.) Unfortunately, thoroughly checking your assembly code is nothing I can simply do en passant.
But there's specifically one thing you can do right now to help me with my analysis in advance: Did I understand your scenario right that your program is meant to be a Windows GUI app, just without any (visible) GUI? Or, in particular, no Windows console app?
Counting from the time stamp of your post #10, your additional 12 hours seem to be over now too. :( I hope all our efforts still are not completely in vain...
Thanks Eri523 :) , you are indeed a great help to me :thumb:
the application has a GUI , ( as you should have known by now by looking at the attachments content- there is an executable Makro.exe - )
currently all i want to do is compiling and making that Makro.exe out of its source code .i dont plan on hiding the GUI nor i want to use the console for this app. just a method to have a successful compilation of this example :)
(after figuring out how i can compile and build this GUI assembly sample, i can modify it as i wish and test different scenarios on it and see the change in behavior of the program :) , without having a successful build, i cant check whether my changes were ok or not :) )
and about the time , my brother has'nt called , so i think i have alittle more time , though im not sure , in anycase i should get this sample to work or i wont let it alone :)
-
Re: a program which repeats users action
i could finally get this sample to compile :)
now i have two issues concerning this sample .
first : i found out this app works only under windows 98!! and probably 2000 , but not XP! why?(windows API differs between these Versions? if it is so why do i have successful compilation under windows xp? )
second and the most important section :
i'm having trouble changing the sample so that it only uses 1 file name to record/play the events.
the problem is , i have to (Open rec file ) choose the file name manually and then press Play or it says file cant be found !.
specifying the path statically wont work!
i checked the source code , and checked the section which deals with opening a file dialog .
its :
Code:
;-------------------------------------------------------------------------
; open button is pressed...
;_________________________________________________________________________
.ELSEIF ax == IDC_P_OPEN
invoke GetOpenFileName,addr ofn
.IF eax != 0
invoke SetDlgItemText,hWnd,IDC_P_EDIT,addr Buffer
.ENDIF
to my opinion disabling all above must not effect the code , because i couldnt find any use for ofn! ! but then again if i disable this two lines of code , i get the message , file not found!
and these are the codes for Play button :
Code:
;-------------------------------------------------------------------------
; play button is pressed...
;_________________________________________________________________________
.IF ax == IDC_P_PLAY
.IF hookflag == 0
mov stopflag,0
mov sleepflag,0
mov lasttime,0
invoke GetDlgItemText,hWnd,IDC_P_EDIT,addr playfilename,sizeof playfilename
invoke CreateFile,addr playfilename,GENERIC_READ,0,+\
NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0
.IF eax != INVALID_HANDLE_VALUE
mov fhandle,eax
invoke ReadFile,fhandle,addr oheader,12,addr byteswritten,0
.IF oheader == 1246259
invoke CloseWindow,hWnd
invoke SetWindowsHookEx,WH_JOURNALPLAYBACK,addr PlaybckProc,NULL,0
mov hhandle,eax
.ELSE
invoke CloseHandle,fhandle
invoke MessageBox,hWnd,addr msg1,addr caption,MB_OK
.ENDIF
.ELSE
invoke MessageBox,hWnd,addr msg2,addr caption,MB_OK ;errormsg
.ENDIF
.ENDIF
i already set the playfilename sth as "norec.rec" or ( "C:\test.rec" )
and as you see there is nothing to do with that ofn!!
and this is were i get the error !
msg2 contains the error message :
Code:
msg2 db "sorry can't find file or file is damaged!",0
anyhelp ? i just drove me insane ! :confused:
-
Re: a program which repeats users action
First, pardon my currently low responsiveness. Sometimes seemingly easy things can turn out to be much more time-consuming than expected... :o
Quote:
Originally Posted by
Master.
first : i found out this app works only under windows 98!! and probably 2000 , but not XP! why?(windows API differs between these Versions? if it is so why do i have successful compilation under windows xp? )
Of course there are differences in the API between those versions, but if that was the reason for your problems I would rather expect your program to work under XP but not 98, and not the other way 'round. I suspect a permission issue. Up to Win 98 (well, more exactly, ME) any program could practically do anything it wants. It stopped being that simple with XP (and that probably applies to 2000 too).
Quote:
second and the most important section :
i'm having trouble changing the sample so that it only uses 1 file name to record/play the events.
I'm not sure whether I really understand how makro.exe and play.exe relate. Isn't one for recording and the other one for playback?
Quote:
the problem is , i have to (Open rec file ) choose the file name manually and then press Play or it says file cant be found !.
specifying the path statically wont work!
i checked the source code , and checked the section which deals with opening a file dialog .
[...]
to my opinion disabling all above must not effect the code , because i couldnt find any use for ofn! ! but then again if i disable this two lines of code , i get the message , file not found!
and these are the codes for Play button :
[...]
You're right in that the Play button handler code (second snippet) doesn't access the ofn structure, but both snippets access the IDC_P_EDIT control's window text property and that's the "variable" they communicate over.
I think you can set up a default file name by setting up the initial text in that edit control. At the moment I have no idea how to do that in your assembly code, though. (It would be so easy in Windows Forms... :rolleyes:)
-
Re: a program which repeats users action
Quote:
Originally Posted by
Eri523
First, pardon my currently low responsiveness. Sometimes seemingly easy things can turn out to be much more time-consuming than expected... :o
Of course there are differences in the API between those versions, but if that was the reason for your problems I would rather expect your program to work under XP but not 98, and not the other way 'round. I suspect a permission issue. Up to Win 98 (well, more exactly, ME) any program could practically do anything it wants. It stopped being that simple with XP (and that probably applies to 2000 too).
I'm not sure whether I really understand how makro.exe and play.exe relate. Isn't one for recording and the other one for playback?
You're right in that the Play button handler code (second snippet) doesn't access the ofn structure, but both snippets access the IDC_P_EDIT control's window text property and that's the "variable" they communicate over.
I think you can set up a default file name by setting up the initial text in that edit control. At the moment I have no idea how to do that in your assembly code, though. (It would be so easy in Windows Forms... :rolleyes:)
about the Makro and Play , they are independent .
while Makro is used to record and play, Play.exe is only used to run the pre recorded file at back ground through command prompt :) .
i'll give it a try and then let you know what i found out :)
thank you again :)
-
Re: a program which repeats users action
Ok thanks to God its done :)
with a simple line of code:
Code:
invoke SetDlgItemText,hWnd,IDC_P_EDIT,addr myFileName
now i need to set a timer ,
how can i do that ?
(unless i need to use loops to simulate that timer! ) .
-
Re: a program which repeats users action
Quote:
Originally Posted by
Master.
now i need to set a timer ,
how can i do that ?
I see some options, depending on what you want to do with that timer. Perhaps the simplest one is a call to Sleep() but that's not appropriate in all situations. Then there are Windows Timers which can be used in two ways: They can be set up to fire a window message or to call a callback function. (And there are certainly yet some other options that don't come to mind now.)
Quote:
(unless i need to use loops to simulate that timer! ) .
Oh no! :eek: Not that again!
You're kidding, aren't you? ;)
-
Re: a program which repeats users action
all i want to do is to record {sleep } show and then again record { pause } show and so on .
so far there are buttons ! i need to get rid of them and implement such a thing .
whats your idea on this ?
-
Re: a program which repeats users action
If I understand you correctly (not 100% sure), Sleep() is no option here because your recording process is event-driven.
So it's got to be a Windows Timer. I think it's mainly a matter of taste whether you prefer the timer to send WM_TIMER messages or use the callback method. To me it looks like what you want is a one-shot timer. This behavior isn't directly supported by the Windows Timer, but you can implement it by killing the timer in the first invocation of your timer tick handler.
Your description of the scenario sounds to me as if you expect the user to pause after performing a single action on his app you're controlling and wait for the "echo" from your app before going on. If this is not the case, you suddenly have a much more complex scenario. In that case I think you would need some sort of queue of user actions that are time-stamped in some way to allow a correctly timed playback. (And a one-shot timer wouldn't do then.)
-
Re: a program which repeats users action
ok .
i came up with the timer solution . on timer tick , i call a method inwhich Record and Play are initiated each time .
but i have a problem here . i dont know how to invoke a button click ? i mean i know it can be done with SendMessage , but in this sample ! i have no idea how to go about it .
i would really really appreciate any one helping on this cause i really have got no time left ( only two hours left :( )
if im done with this part, its over , if not im dead (×_×)
Code:
onTimerTick proc hWnd:DWORD,mode2:WORD
; local mode 0
.IF mode2 == 0 ;start record
mov realmode, 1
;to test to see if this proc works well .( it does :) )
;invok e MessageBox, NULL, addr MsgBoxText1, addr MsgBoxCaption1, MB_OK
;How to simulate the Record button click here?
mov ax , IDC_R_RECORD
.ENDIF
.IF mode2 == 1 ;start playing
mov realmode , 0
;for testing whether this proc works well or not
;invok e MessageBox, NULL, addr MsgBoxText2, addr MsgBoxCaption2, MB_OK
; how to simulate the play button click ?
mov ax , IDC_P_PLAY
;invoke SendMessage,IDC_P_PLAY,NULL,NULL
.ENDIF
ret
onTimerTick endp
thanks in advance
-
Re: a program which repeats users action
ok i came up with this . thanks to God , everything works fine except a problem with file:
here is the code:
Code:
onTimerTick proc hWnd:DWORD,mode2:WORD
; local mode 0
.IF mode2 == 0
mov realmode, 1
;start record
;invok e MessageBox, NULL, addr MsgBoxText1, addr MsgBoxCaption1, MB_OK
;;;;;;;;;;;;;;;;;;;;;;;record
;.IF 0 == 0
; mov stopflag,0
; mov hookflag,1
invoke SetDlgItemText,hWnd,IDC_R_RECORD,addr text1 ;IDC_R_RECORD.Text = "stop recording";
invoke GetDlgItemText,hWnd,IDC_R_EDIT,addr recfilename,sizeof recfilename
.IF eax == 0
invoke lstrcpy,addr recfilename,addr default
invoke SetDlgItemText,hWnd,IDC_R_EDIT,addr default
.ELSE
;invoke lstrcat,addr recfilename,addr fileext
invoke lstrcpy,addr recfilename,addr playfilename ; only use one filename
.ENDIF
invoke CreateFile,addr recfilename,GENERIC_READ+GENERIC_WRITE,0,+\
NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0
mov fhandle,eax
invoke GetTickCount
mov time,eax
mov msgnbr,0
invoke WriteFile,fhandle,addr header,12,addr byteswritten,0
invoke SetWindowsHookEx,WH_JOURNALRECORD,addr RecordProc,NULL,0
mov hhandle,eax
.ELSE
mov hookflag,0
invoke SetDlgItemText,hWnd,IDC_R_RECORD,addr text2 ;start msg
invoke SetFilePointer,fhandle,0,0,FILE_BEGIN
invoke WriteFile,fhandle,addr header,12,addr byteswritten,0
invoke CloseHandle,fhandle
invoke UnhookWindowsHookEx,hhandle
.ENDIF
;.ENDIF
;;;;;;;;;;;;;;;;;;;;;;;;;
;.ENDIF
.IF mode2 == 1
mov realmode , 0
;start playing
;invok e MessageBox, NULL, addr MsgBoxText2, addr MsgBoxCaption2, MB_OK
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;play
;.IF hookflag == 0
; mov stopflag,0
; mov sleepflag,0
; mov lasttime,0
invoke SetDlgItemText,hWnd,IDC_P_EDIT,addr playname ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;maz ezafe kardam
invoke GetDlgItemText,hWnd,IDC_P_EDIT,addr playfilename,sizeof playfilename
invoke CreateFile,addr playfilename,GENERIC_READ,0,+\
NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0
;invoke SetDlgItemText,hWnd,IDC_P_EDIT,addr empty ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;maz ezafe kardam-2
.IF eax != INVALID_HANDLE_VALUE
mov fhandle,eax
invoke ReadFile,fhandle,addr oheader,12,addr byteswritten,0
.IF oheader == 1246259
invoke CloseWindow,hWnd
invoke SetWindowsHookEx,WH_JOURNALPLAYBACK,addr PlaybckProc,NULL,0
mov hhandle,eax
.ELSE
invoke CloseHandle,fhandle
invoke MessageBox,hWnd,addr msg1,addr caption,MB_OK
.ENDIF
.ELSE
invoke MessageBox,hWnd,addr msg2,addr caption,MB_OK
.ENDIF
.ENDIF
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ret
onTimerTick endp
the problem is i get file is damaged or cant find file , while file is there , for frist execution of the application everything works just fine , but in the next onTimerTick proc call , i get the message "cant find the file or file is damage"
and also system kinda hangs until the error message mentioned above shows up :(
how to solve this ?
-
Re: a program which repeats users action
ok , its over now .
thanks to God , i could make it at last :) , but there are couple of minor bugs though :D .
Eri523 Thank you very much for everything :)
-
1 Attachment(s)
Re: a program which repeats users action
hello all again
i encountered some problems concerning this program .
my first problem is the random error message i get because of not being able to find the file !!! while the file is there next to the executable file! and i must mention that when you run the application , for the first time it can record and play just fine , but when it comes to other ticks ( there is a timer which toggles record/play mode, each 5 seconds )which happens each five seconds , the program says cant find the file!!!
i attached the whole code+demo executable , i would greatly appreciate anyone helping me out .
and the other problem is , when i try to use a variable (elapseTime) as a parameter for the SetTimer() function used in the project, i get that error message ( cant find file! ) . while using explicit value as parameter in SetTimer doesnt give that error !!
any help ?
Note:
( and if you are going to use the Demo executable , remember to do :
Right click on it choose >Properties then >compatibility tab and check >Run this program in compatibility mode for Windows98/Me
-
Re: a program which repeats users action
Quote:
Originally Posted by
Master.
my first problem is the random error message i get because of not being able to find the file !!! while the file is there next to the executable file! and i must mention that when you run the application , for the first time it can record and play just fine , but when it comes to other ticks ( there is a timer which toggles record/play mode, each 5 seconds )which happens each five seconds , the program says cant find the file!!!
You're apparently using a relative path (i.e. a bare file name). That will fail to find the file if the current working directory has changed in the meantime. However, I have no idea what might cause this. It's just my first guess. I'd sugest to test whether using an absolute path instead helps.
Quote:
and the other problem is , when i try to use a variable (elapseTime) as a parameter for the SetTimer() function used in the project, i get that error message ( cant find file! ) . while using explicit value as parameter in SetTimer doesnt give that error !!
I can't imagine how SetTimer could fail with anything like a "file not found", and you're not checking for failure of SetTimer at all. So first check the return value of SetTimer and in case of failure use GetLastError to determine the cause. What you describe there looks like some sort of consequential error.
There's no sample of how you try to pass the variable to SetTimer but note that of course you need to pass it by value, not by reference. However, you're correctly passing by value all the way in the program so why should you fail to do so in this specific case? :ehh:
-
Re: a program which repeats users action
Quote:
Originally Posted by
Eri523
You're apparently using a relative path (i.e. a bare file name). That will fail to find the file if the current working directory has changed in the meantime. However, I have no idea what might cause this. It's just my first guess. I'd sugest to test whether using an absolute path instead helps.
I can't imagine how SetTimer could fail with anything like a "file not found", and you're not checking for failure of SetTimer at all. So first check the return value of SetTimer and in case of failure use GetLastError to determine the cause. What you describe there looks like some sort of consequential error.
There's no sample of how you try to pass the variable to SetTimer but note that of course you need to pass it by value, not by reference. However, you're correctly passing by value all the way in the program so why should you fail to do so in this specific case? :ehh:
hello
thanks dear .
well the first solution didnt work :( , used an absolute path like "C:\noname.rec" and just like before , the first time plays fine but for next tries it fails with that error : file cant be found! "
the irony is there are cases where the application works up to 3 or four tries and this is all by chance ! it happens one time , and it doesn't happen the other time !
and about that SetTimer, i dont know either ,
when i write
Code:
invoke SetTimer,hWnd,1,5000,NULL
everything works fine , but when i try to use :
Code:
invoke SetTimer,hWnd,1,elapsetime,NULL
i get that error ( file not found ! at runtime ! )
and i should say sth , the file not found error is shown by a messagebox , the irony here is , when i use the second method of calling SetTimer , the messagebox is just a blank white rectangle ! without any border !
here is the pic:
http://www.imagemoon.us/thumbs/17110IMMwierd_mb.JPG
-
Re: a program which repeats users action
Quote:
Originally Posted by
Master.
Code:
invoke SetTimer,hWnd,1,elapsetime,NULL
Looks ok, but actually I didn't expect anything else.
The fact that using a fully qualified path doesn't help either (so it's no problem with the CWD), in conjunction with the fact that the number of passes seemingly working correctly until the fault happens isn't constant, to me is an almost certain indication that something gets corrupted. I'd say memory corruption by a bogus write is the most probable cause, but it also can be corruption of registers, like ESP or EIP or even one of the segment registers. So now it's time to run your program in the debugger and see what's going on.
I also never have seen a message box like that. Looks like a sign of corruption as well, though I can't point to what got corrupted causing that.
-
Re: a program which repeats users action
Quote:
Originally Posted by
Eri523
Looks ok, but actually I didn't expect anything else.
The fact that using a fully qualified path doesn't help either (so it's no problem with the CWD), in conjunction with the fact that the number of passes seemingly working correctly until the fault happens isn't constant, to me is an almost certain indication that something gets corrupted. I'd say memory corruption by a bogus write is the most probable cause, but it also can be corruption of registers, like ESP or EIP or even one of the segment registers. So now it's time to run your program in the debugger and see what's going on.
I also never have seen a message box like that. Looks like a sign of corruption as well, though I can't point to what got corrupted causing that.
ok how to debug it ? i have no idea how to go about it , can you help me out on this ?
-
Re: a program which repeats users action
Unfortunately not. :( I never had the need to debug stand-alone Windows GUI apps written in assembly yet, so I don't have any experience with that.
Doesn't the assembler package you're using include a debugger? At least the one I used last time did. I suppose this debugger then comes with documentation and perhaps this helps to get you started.
If that fails as well, I think we can only hope for someone who already did something like this to read the thread and jump in...
-
Re: a program which repeats users action
does anyone know what is that header?
(in this line of code ?
Code:
invoke WriteFile,fhandle,addr header,12,addr byteswritten,0
)
and why it is 1246259 only ?
i couldnt find anything on MSDN , i would appreciate if anyone can help me out .
-
Re: a program which repeats users action
Quote:
Originally Posted by
Master.
does anyone know what is that header?
(in this line of code ?
Code:
invoke WriteFile,fhandle,addr header,12,addr byteswritten,0
)
and why it is 1246259 only ?
i couldnt find anything on MSDN , i would appreciate if anyone can help me out .
I don't have the slightest idea. I was assuming you had invented that yourself and so know what it's for. :ehh: If not, where did you get it from (apparently not MSDN)? Doesn't that source explain it?
Note that you're not "only" writing that value which appears to be a file type signature: Youre writing 12 bytes which comprises the variables header, time and msgnbr.
Also, you're writing the header to the file but I don't see any reference to it in the context of reading. I don't know your program well enough to tell whether that might be problematic, though.
-
1 Attachment(s)
Re: a program which repeats users action
Quote:
Originally Posted by
Eri523
I don't have the slightest idea. I was assuming you had invented that yourself and so know what it's for. :ehh: If not, where did you get it from (apparently not MSDN)? Doesn't that source explain it?
Note that you're not "only" writing that value which appears to be a file type signature: Youre writing 12 bytes which comprises the variables header, time and msgnbr.
Also, you're writing the header to the file but I don't see any reference to it in the context of reading. I don't know your program well enough to tell whether that might be problematic, though.
i didnt ! i just modified the code to suite my needs !
i downloaded it form here :
http://win32assembly.online.fr/source2.html
i attached the whole Original Program! before!( i re attached it again ) ,
for reading it uses oheader ! i wonder where or when this variable gets filled!! ?
-
Re: a program which repeats users action
Quote:
Originally Posted by
Master.
i attached the whole Original Program! before!( i re attached it again ) ,
Ah, this one. I still have it on my HD.
Quote:
for reading it uses oheader ! i wonder where or when this variable gets filled!! ?
The program reads the first 12 bytes of the input file (the variables oheader, otime and omsgnbr) and compares oheader to the immediate value 1246259:
Code:
;-------------------------------------------------------------------------
; play button is pressed...
;_________________________________________________________________________
.IF ax == IDC_P_PLAY
.IF hookflag == 0
mov stopflag,0
mov sleepflag,0
mov lasttime,0
invoke GetDlgItemText,hWnd,IDC_P_EDIT,addr playfilename,sizeof playfilename
invoke CreateFile,addr playfilename,GENERIC_READ,0,+\
NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0
.IF eax != INVALID_HANDLE_VALUE
mov fhandle,eax
invoke ReadFile,fhandle,addr oheader,12,addr byteswritten,0
.IF oheader == 1246259
invoke CloseWindow,hWnd
invoke SetWindowsHookEx,WH_JOURNALPLAYBACK,addr PlaybckProc,NULL,0
mov hhandle,eax
.ELSE
invoke CloseHandle,fhandle
invoke MessageBox,hWnd,addr msg1,addr caption,MB_OK
.ENDIF
.ELSE
invoke MessageBox,hWnd,addr msg2,addr caption,MB_OK
.ENDIF
.ENDIF
If the comparison fails, the file is considered invalid.
The reason why the comparison is done against an immediate value here instead of the actual header which would be more illustrative (and safer when maintaining the program) is most likely brevity: The CMP instruction to which that .IF eventually gets translated doesn't allow to directly compare two memory locations, so a comparison to header would have needed two instructioons.
header is a constant that is filled by loading the program into memory and never written to later. It is used to be written to the output file as the file type signature, along with the two variables following it in memory.
-
Re: a program which repeats users action
thanks a million Eri523 :)
and about that 12byte ! could it be for this ? :
http://publib.boulder.ibm.com/infoce...ha3c00316.html
if yes, why did he used 12? and not for example 14, or 16?
(i wonder if i looked in a relevant place !)
-
Re: a program which repeats users action
Quote:
Originally Posted by
Master.
Not really. The record described there practically consists only of variable fields, while the header field we're talking about here is rather a magic number. Unlike at least most of which is described in that article, it doesn't translate into readable ASCII text, though. (Note that although many magic numbers used in popular file formats do translate into readable ASCII, of course this isn't essential for the functionality.)
Quote:
if yes, why did he used 12? and not for example 14, or 16?
(i wonder if i looked in a relevant place !)
Actually, only the constant DOWRD (i.e. 4 bytes) header is the magic number. The other 8 bytes are the variables time and msgnbr which seem to be part of the file header, yet are just this: variable. I haven't examined the program close enough to tell what they're used for when reading back in the file later.
-
Re: a program which repeats users action
thank you Eri523 :)
you are indeed a great help to me :)
God bless you man :)
by the way i called the original author ( yeah after 12 years :)) ) and asked him about the header and that magic number , he kindly replied:
" i was a kid when i wrote that, and now i have no idea what that number stood for and ... : ) "
so i think , this remains still a secret :))