OSDN Git Service

Fix bugs process protection.
[ffftp/ffftp.git] / mbswrapper.h
1 // mbswrapper.h
2 // Copyright (C) 2011 Suguru Kawamoto
3 // マルチバイト文字ワイド文字APIラッパー
4
5 #ifndef __MBSWRAPPER_H__
6 #define __MBSWRAPPER_H__
7
8 #include <stdio.h>
9 #include <windows.h>
10 #include <shlobj.h>
11
12 #ifndef DO_NOT_REPLACE
13
14 #undef WinMain
15 #define WinMain WinMainM
16 int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow);
17 #undef LoadLibrary
18 #define LoadLibrary LoadLibraryM
19 HMODULE LoadLibraryM(LPCSTR lpLibFileName);
20 #undef CreateFile
21 #define CreateFile CreateFileM
22 HANDLE CreateFileM(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
23 #undef MessageBox
24 #define MessageBox MessageBoxM
25 int MessageBoxM(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType);
26 #undef FindFirstFile
27 #define FindFirstFile FindFirstFileM
28 HANDLE FindFirstFileM(LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData);
29 #undef FindNextFile
30 #define FindNextFile FindNextFileM
31 BOOL FindNextFileM(HANDLE hFindFile, LPWIN32_FIND_DATAA lpFindFileData);
32 #undef GetLogicalDriveStrings
33 #define GetLogicalDriveStrings GetLogicalDriveStringsM
34 DWORD GetLogicalDriveStringsM(DWORD nBufferLength, LPSTR lpBuffer);
35 #undef RegisterClassEx
36 #define RegisterClassEx RegisterClassExM
37 ATOM RegisterClassExM(CONST WNDCLASSEXA * v0);
38 #undef CreateWindowEx
39 #define CreateWindowEx CreateWindowExM
40 HWND CreateWindowExM(DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName, DWORD dwStyle, int X, int Y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam);
41 #undef GetWindowLong
42 #define GetWindowLong GetWindowLongM
43 LONG GetWindowLongM(HWND hWnd, int nIndex);
44 #undef SetWindowLong
45 #define SetWindowLong SetWindowLongM
46 LONG SetWindowLongM(HWND hWnd, int nIndex, LONG dwNewLong);
47 #undef DefWindowProc
48 #define DefWindowProc DefWindowProcM
49 LRESULT DefWindowProcM(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
50 #undef CallWindowProc
51 #define CallWindowProc CallWindowProcM
52 LRESULT CallWindowProcM(WNDPROC lpPrevWndFunc, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
53 #undef SendMessage
54 #define SendMessage SendMessageM
55 LRESULT SendMessageM(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
56 #undef DefDlgProc
57 #define DefDlgProc DefDlgProcM
58 LRESULT DefDlgProcM(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
59 #undef SendDlgItemMessage
60 #define SendDlgItemMessage SendDlgItemMessageM
61 LRESULT SendDlgItemMessageM(HWND hDlg, int nIDDlgItem, UINT Msg, WPARAM wParam, LPARAM lParam);
62 #undef SetWindowText
63 #define SetWindowText SetWindowTextM
64 BOOL SetWindowTextM(HWND hWnd, LPCSTR lpString);
65 #undef DragQueryFile
66 #define DragQueryFile DragQueryFileM
67 UINT DragQueryFileM(HDROP hDrop, UINT iFile, LPSTR lpszFile, UINT cch);
68 #undef GetCommandLine
69 #define GetCommandLine GetCommandLineM
70 LPSTR GetCommandLineM();
71 #undef GetCurrentDirectory
72 #define GetCurrentDirectory GetCurrentDirectoryM
73 DWORD GetCurrentDirectoryM(DWORD nBufferLength, LPSTR lpBuffer);
74 #undef SetCurrentDirectory
75 #define SetCurrentDirectory SetCurrentDirectoryM
76 BOOL SetCurrentDirectoryM(LPCSTR lpPathName);
77 #undef GetTempPath
78 #define GetTempPath GetTempPathM
79 DWORD GetTempPathM(DWORD nBufferLength, LPSTR lpBuffer);
80 #undef GetFileAttributes
81 #define GetFileAttributes GetFileAttributesM
82 DWORD GetFileAttributesM(LPCSTR lpFileName);
83 #undef GetModuleFileName
84 #define GetModuleFileName GetModuleFileNameM
85 DWORD GetModuleFileNameM(HMODULE hModule, LPCH lpFilename, DWORD nSize);
86 #undef RegOpenKeyEx
87 #define RegOpenKeyEx RegOpenKeyExM
88 LSTATUS RegOpenKeyExM(HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult);
89 #undef RegCreateKeyEx
90 #define RegCreateKeyEx RegCreateKeyExM
91 LSTATUS RegCreateKeyExM(HKEY hKey, LPCSTR lpSubKey, DWORD Reserved, LPSTR lpClass, DWORD dwOptions, REGSAM samDesired, CONST LPSECURITY_ATTRIBUTES lpSecurityAttributes, PHKEY phkResult, LPDWORD lpdwDisposition);
92 #undef RegDeleteValue
93 #define RegDeleteValue RegDeleteValueM
94 LSTATUS RegDeleteValueM(HKEY hKey, LPCSTR lpValueName);
95 #undef RegQueryValueEx
96 #define RegQueryValueEx RegQueryValueExM
97 LSTATUS RegQueryValueExM(HKEY hKey, LPCSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData);
98 #undef RegSetValueEx
99 #define RegSetValueEx RegSetValueExM
100 LSTATUS RegSetValueExM(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE* lpData, DWORD cbData);
101 #undef TextOut
102 #define TextOut TextOutM
103 BOOL TextOutM(HDC hdc, int x, int y, LPCSTR lpString, int c);
104 #undef GetTextExtentPoint32
105 #define GetTextExtentPoint32 GetTextExtentPoint32M
106 BOOL GetTextExtentPoint32M(HDC hdc, LPCSTR lpString, int c, LPSIZE psizl);
107 #undef PropertySheet
108 #define PropertySheet PropertySheetM
109 INT_PTR PropertySheetM(LPCPROPSHEETHEADERA v0);
110 #undef GetOpenFileName
111 #define GetOpenFileName GetOpenFileNameM
112 BOOL GetOpenFileNameM(LPOPENFILENAMEA v0);
113 #undef GetSaveFileName
114 #define GetSaveFileName GetSaveFileNameM
115 BOOL GetSaveFileNameM(LPOPENFILENAMEA v0);
116 #undef HtmlHelp
117 #define HtmlHelp HtmlHelpM
118 HWND HtmlHelpM(HWND hwndCaller, LPCSTR pszFile, UINT uCommand, DWORD_PTR dwData);
119 #undef CreateProcess
120 #define CreateProcess CreateProcessM
121 BOOL CreateProcessM(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation);
122 #undef FindExecutable
123 #define FindExecutable FindExecutableM
124 HINSTANCE FindExecutableM(LPCSTR lpFile, LPCSTR lpDirectory, LPSTR lpResult);
125 #undef ShellExecute
126 #define ShellExecute ShellExecuteM
127 HINSTANCE ShellExecuteM(HWND hwnd, LPCSTR lpOperation, LPCSTR lpFile, LPCSTR lpParameters, LPCSTR lpDirectory, INT nShowCmd);
128 #undef SHBrowseForFolder
129 #define SHBrowseForFolder SHBrowseForFolderM
130 PIDLIST_ABSOLUTE SHBrowseForFolderM(LPBROWSEINFOA lpbi);
131 #undef SHGetPathFromIDList
132 #define SHGetPathFromIDList SHGetPathFromIDListM
133 BOOL SHGetPathFromIDListM(PCIDLIST_ABSOLUTE pidl, LPSTR pszPath);
134 #undef SHFileOperation
135 #define SHFileOperation SHFileOperationM
136 int SHFileOperationM(LPSHFILEOPSTRUCTA lpFileOp);
137 #undef AppendMenu
138 #define AppendMenu AppendMenuM
139 BOOL AppendMenuM(HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCSTR lpNewItem);
140 #undef GetMenuItemInfo
141 #define GetMenuItemInfo GetMenuItemInfoM
142 BOOL GetMenuItemInfoM(HMENU hmenu, UINT item, BOOL fByPosition, LPMENUITEMINFOA lpmii);
143 #undef CreateFontIndirect
144 #define CreateFontIndirect CreateFontIndirectM
145 HFONT CreateFontIndirectM(CONST LOGFONTA *lplf);
146 #undef ChooseFont
147 #define ChooseFont ChooseFontM
148 BOOL ChooseFontM(LPCHOOSEFONTA v0);
149 #undef DialogBoxParam
150 #define DialogBoxParam DialogBoxParamM
151 INT_PTR DialogBoxParamM(HINSTANCE hInstance, LPCSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam);
152 #undef CreateDialogParam
153 #define CreateDialogParam CreateDialogParamM
154 HWND CreateDialogParamM(HINSTANCE hInstance, LPCSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam);
155 #undef mkdir
156 #define mkdir _mkdirM
157 int mkdirM(const char * _Path);
158 #undef _mkdir
159 #define _mkdir _mkdirM
160 int _mkdirM(const char * _Path);
161 #undef rmdir
162 #define rmdir rmdirM
163 int rmdirM(const char * _Path);
164 #undef _rmdir
165 #define _rmdir _rmdirM
166 int _rmdirM(const char * _Path);
167 #undef _mbslen
168 #define _mbslen _mbslenM
169 size_t _mbslenM(const unsigned char * _Str);
170 #undef _mbschr
171 #define _mbschr _mbschrM
172 unsigned char * _mbschrM(const unsigned char * _Str, unsigned int _Ch);
173 #undef _mbsrchr
174 #define _mbsrchr _mbsrchrM
175 unsigned char * _mbsrchrM(const unsigned char * _Str, unsigned int _Ch);
176 #undef _mbsstr
177 #define _mbsstr _mbsstrM
178 unsigned char * _mbsstrM(const unsigned char * _Str, const unsigned char * _Substr);
179 #undef _mbscmp
180 #define _mbscmp _mbscmpM
181 int _mbscmpM(const unsigned char * _Str1, const unsigned char * _Str2);
182 #undef _mbsicmp
183 #define _mbsicmp _mbsicmpM
184 int _mbsicmpM(const unsigned char * _Str1, const unsigned char * _Str2);
185 #undef _mbsncmp
186 #define _mbsncmp _mbsncmpM
187 int _mbsncmpM(const unsigned char * _Str1, const unsigned char * _Str2, size_t _MaxCount);
188 #undef _mbslwr
189 #define _mbslwr _mbslwrM
190 unsigned char * _mbslwrM(unsigned char * _String);
191 #undef _mbsupr
192 #define _mbsupr _mbsuprM
193 unsigned char * _mbsuprM(unsigned char * _String);
194 #undef _mbsninc
195 #define _mbsninc _mbsnincM
196 unsigned char * _mbsnincM(const unsigned char * _Str, size_t _Count);
197 #undef fopen
198 #define fopen fopenM
199 FILE * fopenM(const char * _Filename, const char * _Mode);
200
201 #undef CreateWindow
202 #define CreateWindow(lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam) CreateWindowEx(0L, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)
203 #undef DialogBox
204 #define DialogBox(hInstance, lpTemplate, hWndParent, lpDialogFunc) DialogBoxParam(hInstance, lpTemplate, hWndParent, lpDialogFunc, 0L)
205
206 #endif
207
208 int MtoW(LPWSTR pDst, int size, LPCSTR pSrc, int count);
209 int WtoM(LPSTR pDst, int size, LPCWSTR pSrc, int count);
210 int AtoW(LPWSTR pDst, int size, LPCSTR pSrc, int count);
211 int WtoA(LPSTR pDst, int size, LPCWSTR pSrc, int count);
212 int TerminateStringM(LPSTR lpString, int size);
213 int TerminateStringW(LPWSTR lpString, int size);
214 int TerminateStringA(LPSTR lpString, int size);
215 size_t GetMultiStringLengthM(LPCSTR lpString);
216 size_t GetMultiStringLengthW(LPCWSTR lpString);
217 size_t GetMultiStringLengthA(LPCSTR lpString);
218 int MtoWMultiString(LPWSTR pDst, int size, LPCSTR pSrc);
219 int WtoMMultiString(LPSTR pDst, int size, LPCWSTR pSrc);
220 int AtoWMultiString(LPWSTR pDst, int size, LPCSTR pSrc);
221 int WtoAMultiString(LPSTR pDst, int size, LPCWSTR pSrc);
222 char* AllocateStringM(int size);
223 wchar_t* AllocateStringW(int size);
224 char* AllocateStringA(int size);
225 wchar_t* DuplicateMtoW(LPCSTR lpString, int c);
226 wchar_t* DuplicateMtoWBuffer(LPCSTR lpString, int c, int size);
227 wchar_t* DuplicateMtoWMultiString(LPCSTR lpString);
228 wchar_t* DuplicateMtoWMultiStringBuffer(LPCSTR lpString, int size);
229 char* DuplicateWtoM(LPCWSTR lpString, int c);
230 wchar_t* DuplicateAtoW(LPCSTR lpString, int c);
231 char* DuplicateWtoA(LPCWSTR lpString, int c);
232 void FreeDuplicatedString(void* p);
233
234 int WINAPI WinMainM(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);
235
236 #endif
237