4 |
5 | extern "C" {
6 | COLORREF __declspec(dllexport) __stdcall MyTextColor(HDC hdc, COLORREF crColor);
7 | };
8 |
--------------------------------------------------------------------------------
/ChangeColors/sample/colors.cfg:
--------------------------------------------------------------------------------
1 | 5:000000
2 | 8:00ff00
3 | 14:0000ff
4 |
5 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Sample libraries for IAT Patcher
2 | ===
3 | [](https://ci.appveyor.com/project/hasherezade/iat-patcher-samples)
4 |
5 | Usage:
6 | --
7 | Use [IAT Patcher](https://github.com/hasherezade/IAT_patcher) to hook your program with the chosen library.
8 |
9 | Download:
10 | -
11 | Fresh builds can be downloaded from [the build server](https://ci.appveyor.com/project/hasherezade/iat-patcher-samples) (click on the build and choose the "Artifacts" tab)
12 |
--------------------------------------------------------------------------------
/ShowProc/README.md:
--------------------------------------------------------------------------------
1 | ShowProc - sample library for IAT Patcher* (masm32/WinAsm)
2 | --
3 | *https://github.com/hasherezade/IAT_patcher
4 |
5 | Purpose:
6 | -
7 | Prints list of dynamically loaded modules and functions.
8 |
9 | Output is saved in file: "ProcList.txt"
10 | Format:
11 |
12 | [return_address]; loaded [Name]
13 |
14 | Example:
15 | --
16 |
17 | 19aa50; loaded: KERNEL32.DLL
18 | 19aa6e; loaded: SystemTimeToFileTime
19 | 19aa6e; loaded: SetEvent
20 |
21 | Usage:
22 | --
23 | Use IAT Patcher to hook your program.
24 | Replace:
25 | Kernel32.dll.GetModuleHandleA -> ShowProc.dll.PrintLibNameA
26 | Kernel32.dll.GetProcAddress -> ShowProc.dll.PrintProcName
27 |
--------------------------------------------------------------------------------
/ShowProc/ShowProc.wap:
--------------------------------------------------------------------------------
1 | [PROJECT]
2 | Type=1
3 | ReleaseCommandLine=
4 | DebugCommandLine=
5 | AutoIncFileVersion=0
6 | RCSilent=0
7 | PellesTools=0
8 | [MAKE]
9 | ActiveBuild=0
10 | CompileRC=/v
11 | RCToObj=
12 | Assemble=/c /coff /Cp /nologo
13 | Link=/SUBSYSTEM:WINDOWS /RELEASE /VERSION:4.0
14 | Out=
15 | DebAssemble=/Zi /Zd /c /coff /Cp /nologo
16 | DebLink=/SUBSYSTEM:WINDOWS /DEBUG /DEBUGTYPE:CV /VERSION:4.0 /INCREMENTAL:NO
17 | DebOut=
18 | [FILES]
19 | 1=main.asm
20 | 2=main.def
21 | [SHOWFILE]
22 | 1=00000000000000009C0500008502000000000000030000004700000072
23 | 2=0D0000005B000000A9050000E0020000010000000100000000000000FA
24 |
--------------------------------------------------------------------------------
/ShowProc/main.asm:
--------------------------------------------------------------------------------
1 | ; CC-BY: hasherezade
2 | ; Sample library for IAT Patcher
3 |
4 | .386
5 | .model flat,stdcall
6 | option casemap:none
7 |
8 | include windows.inc
9 |
10 | include kernel32.inc
11 | include msvcrt.inc
12 |
13 | IncludeLib kernel32.lib
14 | includelib msvcrt.lib
15 |
16 | .data
17 | szFileFmt db 'w',0
18 | szFileName db 'ProcList.txt',0
19 |
20 | szFmtS db '%x; loaded: %s', 0ah, 0dh,0
21 | szFmtOrd db '%x; loaded: ', 0ah, 0dh,0
22 |
23 | .data?
24 | hFile HANDLE ?
25 | dwAddr HANDLE ?
26 |
27 | ASSUME FS:NOTHING
28 |
29 | .code
30 | DllEntry proc hInstance:HINSTANCE, reason:DWORD, reserved1:DWORD
31 | .if reason==DLL_PROCESS_ATTACH
32 |
33 | ;create the file
34 | invoke crt_fopen,offset szFileName, offset szFileFmt
35 | mov hFile,eax
36 |
37 | .elseif reason==DLL_PROCESS_DETACH
38 | invoke crt_fclose,hFile
39 | mov hFile, 0
40 | .endif
41 | ret
42 | DllEntry Endp
43 |
44 |
45 | strlen proc string:PSTR
46 | push edx
47 | xor eax,eax
48 |
49 | mov edx, dword ptr[string]
50 | test edx, 0FFFF0000h ; by ordinal? (or NULL)
51 | je _strlen_end
52 |
53 | mov edx, dword ptr[string]
54 | _is_null:
55 |
56 | cmp byte ptr[edx+eax],0
57 | je _strlen_end
58 |
59 | ;printable?
60 | cmp byte ptr[edx+eax],20h
61 | jl _strlen_end
62 | cmp byte ptr[edx+eax],7Fh
63 | jg _strlen_end
64 |
65 | inc eax
66 | jmp _is_null
67 | _strlen_end:
68 | pop edx
69 | ret
70 | strlen endp
71 |
72 |
73 | print_to_file proc lpString:LPCSTR
74 | mov eax, hFile
75 | cmp eax, 0
76 | je _print_end
77 |
78 | invoke strlen,lpString
79 | cmp eax, 0
80 | je _print_ord
81 |
82 | ;invoke crt_printf, addr szFmtS, dwAddr, lpString
83 | invoke crt_fprintf, hFile, addr szFmtS,dwAddr, lpString
84 | jmp _flush_file
85 |
86 | _print_ord:
87 | ;invoke crt_printf, addr szFmtOrd,dwAddr, lpString
88 | invoke crt_fprintf, hFile, addr szFmtOrd,dwAddr, lpString
89 |
90 | _flush_file:
91 | invoke crt_fflush, hFile
92 |
93 | _print_end:
94 | Ret
95 | print_to_file EndP
96 |
97 | va_to_rva proc dwVA:HANDLE
98 | push edx
99 | mov eax, dwVA
100 |
101 | mov edx, dword ptr fs:[30h]
102 | mov edx, [edx+8]
103 | sub eax, edx
104 |
105 | pop edx
106 | Ret
107 | va_to_rva EndP
108 |
109 | PrintProcName proc hModule:HMODULE, lpName:LPCSTR
110 |
111 | ; save return RVA:
112 | mov eax, dword ptr [ebp+4]
113 | invoke va_to_rva, eax
114 | mov dwAddr, eax
115 |
116 | invoke print_to_file,lpName
117 |
118 | invoke_origina1:
119 | invoke GetProcAddress,hModule,lpName
120 | Ret
121 | PrintProcName EndP
122 |
123 | PrintLibNameA proc lpLibName:LPCSTR
124 |
125 | ; save return RVA:
126 | mov eax, dword ptr [ebp+4]
127 | invoke va_to_rva, eax
128 | mov dwAddr, eax
129 |
130 | invoke print_to_file,lpLibName
131 |
132 | invoke_original2:
133 | invoke LoadLibrary,lpLibName
134 | Ret
135 | PrintLibNameA EndP
136 |
137 | End DllEntry
138 |
--------------------------------------------------------------------------------
/ShowProc/main.def:
--------------------------------------------------------------------------------
1 | LIBRARY ShowProc
2 | EXPORTS PrintProcName
3 | EXPORTS PrintLibNameA
4 |
--------------------------------------------------------------------------------