Modifying a program to fake a button press - reverse-engineering

I have an MFC application that I was given (without source code) which opens a window with an 'Update' button, which then performs a very long update after being clicked.
I'd like to modify the program so that when the window is created (or somewhere else such as DoModal), a message is sent to the program to make it think that the button was pressed.
I've been toying around with this for a while in Ida Pro and OllyDbg to no avail. I looked at possibly using PumpMessage, but this did not bring any success.
Any advice?

If you don't like the idea of using a secondary "macro" program, you could patch the original program's binary to call the button's BM_CLICK handler. If you can find some space for the call (minimum 5 bytes without arguments), you can do this with OllyDbg alone (after editing the code, select it, and select "Copy to executable" -> "Selection" from the right-click menu). Otherwise, you'll need to create a new code section with a PE editor (e.g. LordPE or PE Tools) and add your code there (typically you'll want to change a call in the program to a jump to your section, where you perform the original call plus the call to the button's click handler, then jump back to the old position after your patched jump).

There are a few ways to do it using test automation techniques, but the simplest is to simply get the window handle for the button you want and send it a BM_CLICK message. This assumes that you have a working knowledge of C/C++ on Windows. If not, there are other means using .NET or other technologies. I'm not familiar with ida-pro or ollydbg.

See this perl module win32::guitest it could help you to do this.you can write with it a perl script and embed it in your program. or you can use the win32 api that wrap your required needs and use it.

Just create a 2nd program that will lunch it and will send a mouse click using SendInput(...)

Related

Tk's clipboard command sometimes not setting system clipboard

I've noticed that Tk's clipboard command sometimes does not really append to the system clipboard. I've noticed this in other programs previously (tkcon for example) where if I copy some text and try to paste it into another program (notepad for example) I get nothing. Sometimes I need to do the copy again in order to get the text into the clipboard.
I'm currently developing my own text editor (see pure console text editor 2 on the tcler's wiki or on github) and I can't get the clipboard to work accross applications.
The implementation looks simple enough:
clipboard clear
clipboard append -- [join $copy_lines \n]
but it doesn't work. By doesn't work I mean it works within the running application but if I have two applications open and try to copy from the first and paste into the second then it doesn't work.
Not sure what else I need to do. From the documentation it looks like it should work.
Found the problem (at least for my program). My program runs in plain old tclsh, not wish and waits for inputs in a busy loop (peppered with after commands so as to reduce CPU usage). As such, it never enters the event loop. Turns out Tk updates the clipboard in the event loop (presumably on idle) so the system clipboard never gets updated (though the internal data structures stores the copied text just fine).
The solution is to enter the event loop. Ideally I'd refactor my code to use fileevents instead of a while loop. For a quick fix I'm just calling update whenever I process user inputs.
As for Tk in general, it appears that copied text dies with the application. So the copied text is available while the program is running but disappears when the program quits. It doesn't seem to happen on my Ubuntu machine. I guess I've got a daemon running that maintains the clipboard. That's OK. I can live with it for now.

vim: project wide auto suggestion

When using eclipse upon pressing control space, it show a list of all possible matching function calls irrespective of the file locations.
Is there a similar plugin for VIM ?
I am using vim7.4 and shougo's neocomplete (https://github.com/Shougo/neocomplete.vim). I actually switched from shougo's neocomplcache to this plugin. I am so far satisfied with the auto-complete feature provided by the nice plugin.
I don't write php code though, I made two screenshots of one of my python project.
screenshot 1,
left side is a module tmux_cmd.py, right side I have imported the module, when I type the module name, the plugin suggested me all functions/variables in that module.
screenshot 2,
in same module, when I type keywords (load) in this case, the plugin shows me all possible functions. I opened tagbar on right side to show functions in the current module. I can press <TAB> to choose the one I want, or keep typing something else if I just want to have something else, like loadnothing.... In the screenshot I pressed <tab>
You only need to index your project with ctags (see :help tags and :help ctags) and vim's built-in omni completion will do what you want for PHP when you press <c-x><c-o>.
Vim doesn't do auto-completion, though, you'll need a plugin for that like the one cited by kent but there are others.

Does chrome dev tools have anything similar to sublime text's snippets and tab triggers?

When I'm writing code in sublime text, I have the ability to create "snippets" that I can "tabtrigger" into my code.
For example, If I'm writing some js code and I want to log something to the console, I created a snippet so that all I have to do is type "log" and hit tab. As soon as I hit tab console.log(); is inserted into my code. Google seems to have a different definition of snippets, and I was wondering if the described functionality is available when writing code directly in the dev tools source panel?
I did not find this Tab trigger ability in Chrome but a way to simmulate this operation:
Using AutoHotKey
Run it after installing , and right click AutoHotKey in the taskbar corner -> Edit This Script
Add the following to the script files.
#IfWinActive Developer Tools -
::ml::
SendInput {Raw}margin-left:10px;
return
write your own script like above, then save it and Reload This Script
Have fun!
More to say:
#IfWinActive means this part only applies to the current window whose name started with Developer Tools - .So if you want this script work, you shoul make the develop window seperated from the main Chrome window to have this window name.
::ml:: defines the keys to trigger, the starting :: means this is a word , which can only trigger when it is followed by a space key or an enter key or a tab key a semicolon key and so on. Otherwise it will soon output margin-left:10px; once you typed ml .
SendInput with {Raw} can avoid triggerring endless loop. eg. bb -> border-bottom:1px solid #bbb; the output is ended with bb; and AutoHotKey will auto minimize the current window to avoid endless loop.

How to configure FlashDevelop for unit test builds?

I'm using AsUnit for unit-testing my current AS3 project. My Main() is basically:
if ( UnitTest )
runUnitTests();
else
runMainProgram();
where I change UnitTest before building depending on whether I want to run the program or run the unit tests. Is there a way that makes it easier to switch between the two modes?
Optimally, I'd use F5 for building with UnitTest=false and another hotkey for building with UnitTest=false. What is the closest I can get with FlashDevelop?
You can do the following in FlashDevelop
if(CONFIG::debug) {
trace("Debug");
} else if(CONFIG::release) {
trace("Release");
}
These correspond to the drop down in the toolbar next to the play button.
See this link: http://www.flashdevelop.org/wikidocs/index.php?title=AS3_Conditional_Compilation
In terms of the shortcut, just create a macro that switches the release mode then hits play. From there you can add any shortcut you would like to your macro. So one shortcut will launch the course into debug/release mode as required.
Also note, you can have other CONFIG::bla's - so you might want to have CONFIG:unit1, CONFIG:unit2, etc, etc. See above link.
Easy solution:
duplicate the FlashDevelop project file (.as3proj) and name it "MyProject_tests.as3proj",
open this project, create a new ProjectTests class and set it as the main class,
change the output SWF in project settings.
Add another project file. To run the test using it as the primary. "Document class" the context menu on the file.
Like Chris mentioned, you can use FlashDevelop's Compiler Constants to do what you need, though it is a bit cumbersome turning these constants on and off.
However, there is a FlashDevelop plugin called Config::Toggle that makes that significantly quicker by providing an additional panel where you can enable/disable boolean constants with 1 click. The linked website describes the value of the plugin far better than I ever could. Hope that helps.

How can I disable "HTML Checking" in NetBeans?

I'm using NetBean's Compile on Save setting, and it's really handy when I'm editing a single file. But when I'm dealing with a pair of (or more) class files and am switching between the files, I have a problem:
The Task tab is nearly worthless since it is littered by HTML "error" messages(+) from many dozens of HTML files in the project that are generated by some external tool. The number of HTML errors swamps out any actual Java errors.
What I want is one of:
A way to tell NB to ignore the directory with the HTML files ("help").
A way to turn off HTML "errors" or even to specify HTML2.
A way to filter "Task" errors by file type, parent folder: all Java is under "com".
I've perused the settings and properties, but found nothing that helps.
<rant> Yet another reason I hate an IDE that use the "Take Everything in the Folder" approach.... </rant>
+ = The files are valid HTML but probably not XHTML. Plus, half the messages end abruptly, with something like: "Unexpected tag <TD> found, expecting one of
I found the answer, or at least one that works for me (NB 6.8, YMMV):
In the Tasks tab, click the filter button in the left,
Choose Edit...
In the Task List Filter dialog:
Click New
Enter a value for Name (such as "No Script Messages"),
Uncheck the Scripting Language Tasks option
Click OK.
If the filter doesn't work immediately, you may wish to close/open the Task window or Netbeans.
Hope that helps someone else.
You can go to Tools->options->Editor->Hint .
You can easily select the right options from there .
I want to use task list to only track my To Do list and It can be a real pain when Netbeans starts showing me #todos from included libraries and all sort of compile errors that I am not interested in. If your use case is like me (not interested in compile errors etc. in task window) then you can do following:- (Netbeans 7.1.2)
1) Tasks window | Right click filter | Edit
To edit the default filter.
Click default filter in left hand panel.
Right hand panel, under Type tab - un-check compile errors and issues
2) You can go to Tools | Options | Miscellaneous
Go to Tasks tab now.
Here you can add/remove the To Do strings that you want.
You can create your own custom todo string or make sure that only one of them is listed (what you use)
Now apply default filter and you will only see your #todo tasks. sane and sweet :D