| 397 | } |
| 398 | |
| 399 | wstring ProcessMemory::ReadString(HWND hwnd, const wstring &address, long type, long len) { |
| 400 | const long maxAuto = 4096; |
| 401 | const long readLen = len > 0 ? len : maxAuto; |
| 402 | if (readLen <= 0) |
| 403 | return L""; |
| 404 | vector<uchar> bin(static_cast<size_t>(readLen)); |
| 405 | if (!ReadRaw(hwnd, address, bin.data(), bin.size())) |
| 406 | return L""; |
| 407 | |
| 408 | if (len <= 0) { |
| 409 | // Auto-length reads stop at the first null character in the selected encoding. |
| 410 | const size_t byteWidth = (type == 1) ? sizeof(wchar_t) : 1; |
| 411 | const size_t used = trimNullByteLength(bin, byteWidth); |
| 412 | bin.resize(used); |
| 413 | } |
| 414 | |
| 415 | switch (type) { |
| 416 | case 1: |
| 417 | return decodeUnicodeBytes(bin); |
| 418 | case 2: |
| 419 | return bytesToWide(bin, CP_UTF8); |
| 420 | case 0: |
| 421 | default: |
| 422 | return bytesToWide(bin, CP_ACP); |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | long ProcessMemory::WriteString(HWND hwnd, const wstring &address, long type, const wstring &value) { |
| 427 | vector<uchar> bin; |
nothing calls this directly
no test coverage detected