MCPcopy Create free account
hub / github.com/WallBreaker2/op / ReadString

Method ReadString

libop/memory/ProcessMemory.cpp:399–424  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

397}
398
399wstring 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
426long ProcessMemory::WriteString(HWND hwnd, const wstring &address, long type, const wstring &value) {
427 vector<uchar> bin;

Callers

nothing calls this directly

Calls 5

trimNullByteLengthFunction · 0.85
decodeUnicodeBytesFunction · 0.85
bytesToWideFunction · 0.85
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected