Skip to content

Commit 1ae594a

Browse files
committed
Refactored some hooked function definitions
1 parent 9993471 commit 1ae594a

File tree

1 file changed

+2
-137
lines changed

1 file changed

+2
-137
lines changed

Shared/sdk/SharedUtil.Win32Utf8FileHooks.hpp

Lines changed: 2 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,8 @@ The hooks in this file modify the following functions to work correctly with utf
3131
MoveFile
3232
DeleteFile
3333
GetModuleHandle
34-
sopen_s
35-
_chdir
36-
_mkdir
37-
_rmdir
38-
remove
39-
rename
4034
41-
The following will also work correctly with utf8 strings as they eventually call the above hooked functions:
42-
43-
fopen
44-
unlink
45-
fstream
35+
Some more will also work correctly with utf8 strings as they eventually call the above hooked functions
4636
4737
BUT
4838
* Many other functions are not hooked and will need utf8 conversions when used, like these:
@@ -59,138 +49,13 @@ BUT
5949
namespace SharedUtil
6050
{
6151

62-
/////////////////////////////////////////////////////////////
63-
//
64-
// Function defs
65-
//
66-
/////////////////////////////////////////////////////////////
67-
68-
typedef
69-
HANDLE
70-
(WINAPI
71-
*FUNC_CreateFileA)(
72-
__in LPCSTR lpFileName,
73-
__in DWORD dwDesiredAccess,
74-
__in DWORD dwShareMode,
75-
__in_opt LPSECURITY_ATTRIBUTES lpSecurityAttributes,
76-
__in DWORD dwCreationDisposition,
77-
__in DWORD dwFlagsAndAttributes,
78-
__in_opt HANDLE hTemplateFile
79-
);
80-
81-
typedef
82-
HMODULE
83-
(WINAPI
84-
*FUNC_LoadLibraryA)(
85-
__in LPCSTR lpLibFileName
86-
);
87-
88-
typedef
89-
HMODULE
90-
(WINAPI
91-
*FUNC_LoadLibraryExA)(
92-
__in LPCSTR lpLibFileName,
93-
__reserved HANDLE hFile,
94-
__in DWORD dwFlags
95-
);
96-
97-
typedef
98-
BOOL
99-
(WINAPI
100-
*FUNC_SetDllDirectoryA)(
101-
__in_opt LPCSTR lpPathName
102-
);
103-
104-
typedef
105-
BOOL
106-
(WINAPI
107-
*FUNC_SetCurrentDirectoryA)(
108-
__in LPCSTR lpPathName
109-
);
110-
111-
typedef int (WINAPI *FUNC_AddFontResourceExA)( __in LPCSTR name, __in DWORD fl, __reserved PVOID res);
112-
typedef BOOL (WINAPI *FUNC_RemoveFontResourceExA)( __in LPCSTR name, __in DWORD fl, __reserved PVOID pdv);
113-
114-
typedef
115-
BOOL
116-
(WINAPI
117-
*FUNC_RemoveDirectoryA)(
118-
__in LPCSTR lpPathName
119-
);
120-
121-
typedef
122-
BOOL
123-
(WINAPI
124-
*FUNC_GetDiskFreeSpaceExA)(
125-
__in_opt LPCSTR lpDirectoryName,
126-
__out_opt PULARGE_INTEGER lpFreeBytesAvailableToCaller,
127-
__out_opt PULARGE_INTEGER lpTotalNumberOfBytes,
128-
__out_opt PULARGE_INTEGER lpTotalNumberOfFreeBytes
129-
);
130-
131-
typedef
132-
DWORD
133-
(WINAPI
134-
*FUNC_GetFileAttributesA)(
135-
__in LPCSTR lpFileName
136-
);
137-
138-
typedef
139-
BOOL
140-
(WINAPI
141-
*FUNC_SetFileAttributesA)(
142-
__in LPCSTR lpFileName,
143-
__in DWORD dwFileAttributes
144-
);
145-
146-
typedef HINSTANCE (STDAPICALLTYPE *FUNC_ShellExecuteA)(HWND hwnd, LPCSTR lpOperation, LPCSTR lpFile, LPCSTR lpParameters,
147-
LPCSTR lpDirectory, INT nShowCmd);
148-
149-
typedef
150-
BOOL
151-
(WINAPI
152-
*FUNC_CreateDirectoryA)(
153-
__in LPCSTR lpPathName,
154-
__in_opt LPSECURITY_ATTRIBUTES lpSecurityAttributes
155-
);
156-
157-
typedef
158-
BOOL
159-
(WINAPI
160-
*FUNC_CopyFileA)(
161-
__in LPCSTR lpExistingFileName,
162-
__in LPCSTR lpNewFileName,
163-
__in BOOL bFailIfExists
164-
);
165-
166-
typedef
167-
BOOL
168-
(WINAPI
169-
*FUNC_MoveFileA)(
170-
__in LPCSTR lpExistingFileName,
171-
__in LPCSTR lpNewFileName
172-
);
173-
174-
typedef
175-
BOOL
176-
(WINAPI
177-
*FUNC_DeleteFileA)(
178-
__in LPCSTR lpFileName
179-
);
180-
181-
typedef
182-
HMODULE
183-
(WINAPI
184-
*FUNC_GetModuleHandleA)(
185-
__in_opt LPCSTR lpModuleName
186-
);
187-
18852
/////////////////////////////////////////////////////////////
18953
//
19054
// Hook variables
19155
//
19256
/////////////////////////////////////////////////////////////
19357
#define HOOKVAR(name) \
58+
using FUNC_##name = decltype(&name); \
19459
FUNC_##name pfn##name;
19560

19661
HOOKVAR( CreateFileA )

0 commit comments

Comments
 (0)