Skip to content

Commit 4e0b679

Browse files
committed
seperate and add more windyn files
1 parent 27d098f commit 4e0b679

8 files changed

Lines changed: 823 additions & 295 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Projects based on this repo:
2424

2525
In `project`, `Makefile` for `gcc` (llvm-mingw or mingw-w64), `tcc` (not support inline) and `sln` for `msvc`. All of them are compatible for `win xp` and above.
2626

27-
- `windyn.h`, single header file for windows dynamic binding system api without IAT
27+
- `windynkernel32|ntdll|gdi32.h`, single header file for windows dynamic binding system api without IAT
2828
- `winhook.h`, single header file for windows dynamic hook and memory util functions
2929
- `winpe.h`, single header file for windows pe structure, adjusting realoc addrs, or iat
3030
- `winversion.h`, single header file for windows `version.dll` proxy to patch.dll, moved to [Release](https://github.com/YuriSizuku/toolkit-Override)

project/windll_winhook/src/libwinhook_test.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void test_patchpattern()
2525
res = sprintf(tmp, "%p:09\r\n", (void*)((size_t)&v2 + 3));
2626
strcat(pattern, tmp);
2727
puts(pattern);
28-
res = winhook_patchmemorypattern(pattern);
28+
res = winhook_patchp(pattern);
2929
printf("[test_patchpattern] after patch, v1(%p)=%x v2(%p)=%x\n", &v1, v1, &v2, v2);
3030
assert(res == 5);
3131
assert(v1 == 0xff);
@@ -56,7 +56,7 @@ void test_patch1337()
5656
res = sprintf(tmp, "%p:%02X->09\n", (void*)((size_t)&v2 - base + 3), (uint8_t)(v2 >> 24) & 0xff);
5757
strcat(pattern, tmp);
5858
puts(pattern);
59-
res = winhook_patchmemory1337(pattern, 0, FALSE);
59+
res = winhook_patch1337(pattern, 0, FALSE);
6060
printf("[test_patch1337] after patch, v1(%p)=%x v2(%p)=%x\n", &v1, v1, &v2, v2);
6161
assert(res == 5);
6262
assert(v1 == 0xff);
@@ -82,7 +82,7 @@ void test_patchips()
8282
*p++ = 0x12; *p++ = 0xab; *p++ = 0xcd; *p++ = 0x09; // patch2
8383
strncpy((char*)p, "EOF", 3);
8484
puts(pattern);
85-
res = winhook_patchmemoryips(pattern, base);
85+
res = winhook_patchips(pattern, base);
8686
printf("[test_patchips] after patch, v[0](%p)=%x v[1](%p)=%x\n", &v[0], v[0], &v[1], v[1]);
8787
assert(res == 5);
8888
assert(v[0] == 0xff);
@@ -96,23 +96,23 @@ void test_searchpattern()
9696
char* pattern2 = "22 ? 2? 33 44 ?";
9797
size_t matchsize = 0;
9898
void* matchaddr = NULL;
99-
matchaddr = winhook_searchmemory(target, sizeof(target), pattern, &matchsize);
100-
printf("[test_searchpattern] winhook_searchmemory matchaddr=%p, matchsize=0x%zx pattern=%s\n",
99+
matchaddr = winhook_search(target, sizeof(target), pattern, &matchsize);
100+
printf("[test_searchpattern] winhook_search matchaddr=%p, matchsize=0x%zx pattern=%s\n",
101101
matchaddr, matchsize, pattern);
102-
matchaddr = winhook_searchmemoryex(GetCurrentProcess(), target, sizeof(target), pattern, &matchsize);
103-
printf("[test_searchpattern] winhook_searchmemoryex matchaddr=%p, matchsize=0x%zx pattern=%s\n",
102+
matchaddr = winhook_searchex(GetCurrentProcess(), target, sizeof(target), pattern, &matchsize);
103+
printf("[test_searchpattern] winhook_searchex matchaddr=%p, matchsize=0x%zx pattern=%s\n",
104104
matchaddr, matchsize, pattern);
105-
matchaddr = winhook_searchmemory(target, sizeof(target), pattern2, &matchsize);
106-
printf("[test_searchpattern] winhook_searchmemory matchaddr=%p, matchsize=0x%zx pattern=%s\n",
105+
matchaddr = winhook_search(target, sizeof(target), pattern2, &matchsize);
106+
printf("[test_searchpattern] winhook_search matchaddr=%p, matchsize=0x%zx pattern=%s\n",
107107
matchaddr, matchsize, pattern2);
108108

109109
char target2[] = "\x8B\x4D\xF8\x83\x61\x70\xFD\xC9\xC3\x8B\xFF\x55\x8B\xEC\x6A\x04\x6A\x00\xFF\x75\x08\x6A\x00\xE8\x9A\xFF\xFF\xFF\x83\xC4\x10\x5D\x00";
110110
char* pattern3 = "55 8b ec 6a 04 6a 00 ff 75 08 6a 00 e8";
111-
matchaddr = winhook_searchmemory(target2, sizeof(target2), pattern3, &matchsize);
112-
printf("[test_searchpattern] winhook_searchmemory matchaddr=%p, matchsize=0x%zx pattern=%s\n",
111+
matchaddr = winhook_search(target2, sizeof(target2), pattern3, &matchsize);
112+
printf("[test_searchpattern] winhook_search matchaddr=%p, matchsize=0x%zx pattern=%s\n",
113113
matchaddr, matchsize, pattern3);
114-
matchaddr = winhook_searchmemoryex(GetCurrentProcess(), target2, sizeof(target2), pattern3, &matchsize);
115-
printf("[test_searchpattern] winhook_searchmemoryex matchaddr=%p, matchsize=0x%zx pattern=%s\n",
114+
matchaddr = winhook_searchex(GetCurrentProcess(), target2, sizeof(target2), pattern3, &matchsize);
115+
printf("[test_searchpattern] winhook_searchex matchaddr=%p, matchsize=0x%zx pattern=%s\n",
116116
matchaddr, matchsize, pattern3);
117117
}
118118

project/winsrc_all/build_src.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ build_csrc()
1414
src_dir=$1
1515
dst_dir=$2
1616
module_name=$3
17-
module_ver=$(awk '/.*_VERSION/ {print $3}' $src_dir/$module_name.h | sed 's/"//g')
17+
module_ver=$(awk '/#define.*_VERSION/ {print $3}' $src_dir/$module_name.h | sed 's/"//g')
1818
module_ver=$(echo $module_ver | sed -E 's/\./_/g')
1919
echo build ${module_name}_v${module_ver}.h
2020
cp -f $src_dir/${module_name}.h $dst_dir/${module_name}_v${module_ver}.h
@@ -24,5 +24,7 @@ mkdir -p $(dirname $0)/build
2424
build_pysrc src $(dirname $0)/build windllin
2525
build_csrc src $(dirname $0)/build commdef
2626
build_csrc src $(dirname $0)/build winhook
27-
build_csrc src $(dirname $0)/build windyn
27+
build_csrc src $(dirname $0)/build windynkernel32
28+
build_csrc src $(dirname $0)/build windyngdi32
29+
build_csrc src $(dirname $0)/build windynntdll
2830
build_csrc src $(dirname $0)/build winpe

src/windyngdi32.h

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
/**
2+
* windows gdi32 dynamic binding
3+
* v0.1, developed by devseed
4+
*
5+
* macros:
6+
* WINDYNGDI32_IMPLEMENTATION, include defines of each function
7+
* WINDYN_SHARED, make function export
8+
* WINDYN_STATIC, make function static
9+
* WINDYN_NOINLINE, don't use inline function
10+
*/
11+
12+
#ifndef _WINDYNGDI32_H
13+
#define _WINDYNGDI32_H
14+
#define WINDYNGDI32_VERSION "0.1"
15+
16+
#ifdef __cplusplus
17+
extern "C" {
18+
#endif
19+
#include <windows.h>
20+
21+
#if 1 // winapi pointer declear
22+
23+
typedef HFONT (WINAPI *T_CreateFontA)(
24+
int cHeight,
25+
int cWidth,
26+
int cEscapement,
27+
int cOrientation,
28+
int cWeight,
29+
DWORD bItalic,
30+
DWORD bUnderline,
31+
DWORD bStrikeOut,
32+
DWORD iCharSet,
33+
DWORD iOutPrecision,
34+
DWORD iClipPrecision,
35+
DWORD iQuality,
36+
DWORD iPitchAndFamily,
37+
LPCSTR pszFaceName
38+
);
39+
40+
typedef HFONT (WINAPI *T_CreateFontW)(
41+
int cHeight,
42+
int cWidth,
43+
int cEscapement,
44+
int cOrientation,
45+
int cWeight,
46+
DWORD bItalic,
47+
DWORD bUnderline,
48+
DWORD bStrikeOut,
49+
DWORD iCharSet,
50+
DWORD iOutPrecision,
51+
DWORD iClipPrecision,
52+
DWORD iQuality,
53+
DWORD iPitchAndFamily,
54+
LPCWSTR pszFaceName
55+
);
56+
57+
typedef HFONT (WINAPI *T_CreateFontIndirectA)(
58+
CONST LOGFONTA *lplf
59+
);
60+
61+
typedef HFONT (WINAPI *T_CreateFontIndirectW)(
62+
CONST LOGFONTW *lplf
63+
);
64+
65+
typedef HFONT (WINAPI *T_CreateFontIndirectExA)(
66+
CONST ENUMLOGFONTEXDVA *
67+
);
68+
69+
typedef HFONT (WINAPI *T_CreateFontIndirectExW)(
70+
CONST ENUMLOGFONTEXDVW *
71+
);
72+
73+
typedef int (WINAPI *T_EnumFontFamiliesExA)(
74+
HDC hdc,
75+
LPLOGFONTA lpLogfont,
76+
FONTENUMPROCA lpProc,
77+
LPARAM lParam,DWORD dwFlags
78+
);
79+
80+
typedef int (WINAPI *T_EnumFontFamiliesExW)(
81+
HDC hdc,
82+
LPLOGFONTW lpLogfont,
83+
FONTENUMPROCW lpProc,
84+
LPARAM lParam,
85+
DWORD dwFlags
86+
);
87+
88+
typedef int (WINAPI *T_EnumFontFamiliesA)(
89+
HDC hdc,
90+
LPCSTR lpLogfont,
91+
FONTENUMPROCA lpProc,
92+
LPARAM lParam
93+
);
94+
95+
typedef int (WINAPI *T_EnumFontFamiliesW)(
96+
HDC hdc,
97+
LPCWSTR lpLogfont,
98+
FONTENUMPROCW lpProc,
99+
LPARAM lParam
100+
);
101+
102+
typedef int (WINAPI *T_EnumFontsA)(
103+
HDC hdc,
104+
LPCSTR lpLogfont,
105+
FONTENUMPROCA lpProc,
106+
LPARAM lParam
107+
);
108+
109+
typedef int (WINAPI *T_EnumFontsW)(
110+
HDC hdc,LPCWSTR lpLogfont,
111+
FONTENUMPROCW lpProc,
112+
LPARAM lParam
113+
);
114+
115+
typedef DWORD (WINAPI *T_GetGlyphOutlineA)(
116+
HDC hdc,
117+
UINT uChar,
118+
UINT fuFormat,
119+
LPGLYPHMETRICS lpgm,
120+
DWORD cjBuffer,
121+
LPVOID pvBuffer,
122+
CONST MAT2 *lpmat2
123+
);
124+
125+
typedef DWORD (WINAPI *T_GetGlyphOutlineW)(
126+
HDC hdc,
127+
UINT uChar,
128+
UINT fuFormat,
129+
LPGLYPHMETRICS lpgm,
130+
DWORD cjBuffer,
131+
LPVOID pvBuffer,
132+
CONST MAT2 *lpmat2
133+
);
134+
#endif
135+
136+
#if 1 // windyn declear
137+
#endif
138+
139+
#ifdef WINDYNGDI32_IMPLEMENTATION
140+
#endif
141+
142+
#ifdef __cplusplus
143+
}
144+
#endif
145+
#endif

0 commit comments

Comments
 (0)