WaxfordSqueers
November 30th, 2004, 00:13
Quote:
[Originally Posted by tdennist]All right...don't flame...I looked meticulously through the command reference and attempted a Google search or three...I don't know how to do three things with Softice (and many more, but these are the most important at the moment ;-)):
- Break at the beginning of program execution.
- Finding such "recognizable API" calls as GetStartupInfoA in a running program.
- Jump to a specific code offset. (I have to find the address of the lives variable every time I want to jump to 423A1F, so I can do a bpmb)
Help? *bambi eyes* |
Basically, you use the loader. You'll find it in the Sice directory and it actually has the word 'loader' with it. You should learn how to use the loader anyway, since it's invaluable at times. For example, in your winice.dat file, you are supposed to have certain imports listed to load automatically at startup. With the loader, you can load them after startup. You can also start the app from the loader and tell it where you want it to break...at start of code or at winmain.
There's another way to do it that I haven't used a lot. Actually, there's a small app that will do the same thing. It loads a 0xCC (I think) in place of the first byte of executable code. I'm not sure whether you have to use the loader, or if you can just run the app, but Sice breaks on the 0xCC because it thinks it's a breakpoint. Please check this information for accuracy. At least it will give you something to research and maybe teach you a bit about loading.
Once you've told the loader to begin, it might stop at a strange looking screen that looks like an error happened. Just single-step over the page (<T><Enter>

and you'll be at the very first byte of executable code (note: be sure you choose the first byte of executable code as a stopping point and not winmain. They are not the same.). You were joking about hitting F8 over and over and nothing happening. I don't use F8, prefering <T> plus <Enter>. That gives a single step. If you start single stepping at the first instruction after the loader, and if you have the key imports loaded, like kernel32, user32, MFC, etc., you will notice instructions like the one Kayaker mentioned near the beginning of the code.
You don't want to step into these unless you don't mind being dragged through the kernel for long periods of time. (BTW...I haven't tried to reverse in XP and references to kernel32, etc., may no longer apply). Anyway, when you come to an import like StartupInfo, stop immediately before it and hit <P> plus <Enter>. That will jump you right over to the other side of the import's code.
If you happen to get caught in the import code, you can often extricate yourself if you hit F12 immediately. Or you can hit F5 to make the program run. Of course, it will either go to the end of execution or stop at the next break point. At least you can reload and start over at the beginning of code.
On your way in, single-stepping, you'll arrive at Call instructions. You can jump over some of these, and others you can't. I used to make printouts of the code from the first instruction after the loader. I'd try each call instruction to see how many I could jump over. If one of them threw me to the end of execution, I'd just start over. It teaches you a lot about how apps are loaded and initialized. Eventually, you'll reach the function like GetStartUpInfo, that are in English.
Get a good function reference. I used Win32 Programming API Bible for years, but it's aimed at Win 95. After a while, you can tell by the parameters preceding the function exactly what it is trying to do. Also, you get used to the initialization functions and can save yourself loads of tracing time by jumping over them.
What Kayaker is telling you to do, however, is examine the code around the area of GetStartUpInfo, or one of the early imports. It will be in English characters if you have loaded it's import. That function is part of kernel32 or user32, so these have to be loaded in memory. Otherwise the function will not appear in character form, but as a Call to a numerical address.
You can make your reversing a lot easier by making .nms files using IDA. I haven't done this recently, but what it does is give character handles, in English, to functions rather than the numerical values you usually see in MFC code.
Print out a page of the code while you're in Sice, then go looking for the GetStartUpInfo function in IDA. The offsets should match, and the code should be the same. If they are different, check the exact differences in offsets, and that should be transferrable to the code section you are checking.
To jump to a specific code offset, first get into an area of code where you can stop the app. For example, BPX on GetStartUpInfo and run the app. Sice will break just into GetStartUpInfo. F12 over it so you're at the instruction on the other side of it. I think it's the 'g' instruction you use then (it's horrible when you've been away from this for a while). Anyway, at the Sice prompt, you enter g 0041Dxxx, or whatever the address is you want to jump to. It will take you right there in most cases. Of course, if you have breakpoints set in between, it will stop there first. :-)