Skip to content

Commit

Permalink
win32_utf8(): Add WideCharToMultiByte().
Browse files Browse the repository at this point in the history
  • Loading branch information
nmlgc committed Apr 16, 2014
1 parent 2c93b6a commit df6e55c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
5 changes: 3 additions & 2 deletions thcrap/src/win32_detour.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

void win32_detour(void)
{
detour_cache_add("kernel32.dll", 20,
detour_cache_add("kernel32.dll", 21,
"CreateDirectoryA", CreateDirectoryU,
"CreateFileA", CreateFileU,
"CreateProcessA", CreateProcessU,
Expand All @@ -31,7 +31,8 @@ void win32_detour(void)
"MoveFileA", MoveFileU,
"MoveFileExA", MoveFileExU,
"MoveFileWithProgressA", MoveFileWithProgressU,
"SetCurrentDirectoryA", SetCurrentDirectoryU
"SetCurrentDirectoryA", SetCurrentDirectoryU,
"WideCharToMultiByte", WideCharToMultiByteU
);

detour_cache_add("gdi32.dll", 3,
Expand Down
17 changes: 17 additions & 0 deletions win32_utf8/src/kernel32_dll.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,23 @@ BOOL WINAPI SetCurrentDirectoryU(
return Wrap1P((Wrap1PFunc_t)SetCurrentDirectoryW, lpPathName);
}

int WINAPI WideCharToMultiByteU(
__in UINT CodePage,
__in DWORD dwFlags,
__in_ecount(cchWideChar) LPCWSTR lpWideCharStr,
__in int cchWideChar,
__out_bcount_opt(cbMultiByte) __transfer(lpWideCharStr) LPSTR lpMultiByteStr,
__in int cbMultiByte,
__in_opt LPCSTR lpDefaultChar,
__out_opt LPBOOL lpUsedDefaultChar
)
{
return WideCharToMultiByte(
CP_UTF8, 0, lpWideCharStr, cchWideChar,
lpMultiByteStr, cbMultiByte, NULL, NULL
);
}

// Patcher functions
// -----------------
int kernel32_init(HMODULE hMod)
Expand Down
11 changes: 11 additions & 0 deletions win32_utf8/src/kernel32_dll.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,17 @@ BOOL WINAPI SetCurrentDirectoryU(
#undef SetCurrentDirectory
#define SetCurrentDirectory SetCurrentDirectoryU

int WINAPI WideCharToMultiByteU(
__in UINT CodePage,
__in DWORD dwFlags,
__in_ecount(cchWideChar) LPCWSTR lpWideCharStr,
__in int cchWideChar,
__out_bcount_opt(cbMultiByte) __transfer(lpWideCharStr) LPSTR lpMultiByteStr,
__in int cbMultiByte,
__in_opt LPCSTR lpDefaultChar,
__out_opt LPBOOL lpUsedDefaultChar
);

// Patchers
int kernel32_init(HMODULE hMod);
void kernel32_exit(void);
1 change: 1 addition & 0 deletions win32_utf8/win32_utf8.def
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ EXPORTS
MoveFileExU
MoveFileWithProgressU
SetCurrentDirectoryU
WideCharToMultiByteU

; psapi.dll
; ---------
Expand Down

0 comments on commit df6e55c

Please sign in to comment.