The Windows mode application (GUI) enables the console by:
Steps |
Method |
1 Startup/Shutdown console |
AllocConsole () Freeconsole () |
2 redirect input/output |
Freopen ("conin$", "R", stdin) Freopen ("conout$", "w", stdout) Freopen ("conout$", "W", stderr) |
3 Console input/output |
#include <conio.h> #include <stdio.h> printf (...) scanf (...) System ("Pause") |
Two, the hook API function simple method is:
1. In debug mode, the function name value is the address of the instruction "jmp function body". The instruction format is "e9----" and the accompanying parameter is a four-byte transfer offset. Therefore, the function name Value + * (dword*) (DWORD) function name value + 1) is the function body entry address. "Use go To Disassembly" function calculates the function body entrance stack instruction length, obtains the actual entry address is "function name Value + * (dword*) ((DWORD) function name value + 1) + The entrance stack instruction length";
2. In release mode, the function name value is directly the entry address of the function body. Using the function of "go to disassembly" to compute the instruction length of function body except exit instruction, the function exit address is "function name + instruction Length", and API function is this mode.
3. Use ":: WriteProcessMemory (:: GetCurrentProcess (), API function export Address ...)" method to hook up the following calls on an API function:
Serial number |
Description |
Instructions |
Parameter values |
1 |
Call hook function |
e8---- |
hook function Body Actual entry address |
2 |
Exit |
c2-- |
Total length of function parameters to restore the state of the stack |