Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ if (WIBO_ENABLE_FIXTURE_TESTS)
wibo_add_fixture_bin(NAME test_bcrypt SOURCES test/test_bcrypt.c COMPILE_OPTIONS -lbcrypt)
wibo_add_fixture_bin(NAME test_shlwapi SOURCES test/test_shlwapi.c COMPILE_OPTIONS -lshlwapi)
wibo_add_fixture_bin(NAME test_ws2 SOURCES test/test_ws2.c COMPILE_OPTIONS -lws2_32)
wibo_add_fixture_bin(NAME test_charupperbuff SOURCES test/test_charupperbuff.c COMPILE_OPTIONS -luser32)
wibo_add_fixture_bin(NAME test_resources SOURCES test/test_resources.c ${WIBO_TEST_BIN_DIR}/test_resources_res.o COMPILE_OPTIONS -lversion)
wibo_add_fixture_bin(NAME test_threading SOURCES test/test_threading.c)
wibo_add_fixture_bin(NAME test_temppath SOURCES test/test_temppath.c)
Expand Down
19 changes: 19 additions & 0 deletions dll/user32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "kernel32/internal.h"
#include "modules.h"
#include "resources.h"
#include "strutil.h"

#include <cstring>

Expand All @@ -22,6 +23,24 @@ struct USEROBJECTFLAGS {
DWORD dwFlags;
};

DWORD WINAPI CharUpperBuffW(LPWSTR lpsz, DWORD cchLength) {
HOST_CONTEXT_GUARD();
DEBUG_LOG("CharUpperBuffW(%p, %u)\n", lpsz, cchLength);
if (!lpsz) {
return 0;
}
for (DWORD i = 0; i < cchLength; ++i) {
lpsz[i] = wcharToUpper(lpsz[i]);
}
return cchLength;
}

LPSTR WINAPI CharNextA(LPCSTR lpsz) {
HOST_CONTEXT_GUARD();
DEBUG_LOG("CharNextA(%p)\n", lpsz);
return const_cast<LPSTR>(*lpsz ? lpsz + 1 : lpsz);
}

int WINAPI LoadStringA(HMODULE hInstance, UINT uID, LPSTR lpBuffer, int cchBufferMax) {
HOST_CONTEXT_GUARD();
DEBUG_LOG("LoadStringA(%p, %u, %p, %d)\n", hInstance, uID, lpBuffer, cchBufferMax);
Expand Down
2 changes: 2 additions & 0 deletions dll/user32.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace user32 {

DWORD WINAPI CharUpperBuffW(LPWSTR lpsz, DWORD cchLength);
LPSTR WINAPI CharNextA(LPCSTR lpsz);
int WINAPI LoadStringA(HMODULE hInstance, UINT uID, LPSTR lpBuffer, int cchBufferMax);
int WINAPI LoadStringW(HMODULE hInstance, UINT uID, LPWSTR lpBuffer, int cchBufferMax);
int WINAPI MessageBoxA(HWND hwnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType);
Expand Down
23 changes: 23 additions & 0 deletions test/test_charupperbuff.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <windows.h>

#include "test_assert.h"

int main(void) {
char text[] = "ab";
WCHAR buffer[] = {'a', 'B', 0, 'c', 'x'};
DWORD result;

result = CharUpperBuffW(buffer, 4);
TEST_CHECK_EQ(4, result);
TEST_CHECK_EQ('A', buffer[0]);
TEST_CHECK_EQ('B', buffer[1]);
TEST_CHECK_EQ(0, buffer[2]);
TEST_CHECK_EQ('C', buffer[3]);
TEST_CHECK_EQ('x', buffer[4]);
TEST_CHECK_EQ(0, CharUpperBuffW(NULL, 1));

TEST_CHECK(CharNextA(text) == text + 1);
TEST_CHECK(CharNextA(text + 1) == text + 2);
TEST_CHECK(CharNextA(text + 2) == text + 2);
return 0;
}
Loading