| 493 | } |
| 494 | |
| 495 | size_t ProcessMemory::str2address(const wstring &caddress) { |
| 496 | wstring address = caddress; |
| 497 | if (!checkaddress(address)) |
| 498 | return 0; |
| 499 | |
| 500 | vector<size_t> sk; |
| 501 | size_t idx1 = address.find(L'<'); |
| 502 | size_t idx2 = address.find(L'>'); |
| 503 | if (idx1 != wstring::npos && idx2 != wstring::npos && idx1 < idx2) { |
| 504 | auto mod_name = address.substr(idx1 + 1, idx2 - idx1 - 1); |
| 505 | HMODULE hmod = NULL; |
| 506 | if (_hwnd == 0) |
| 507 | hmod = ::GetModuleHandleW(mod_name.data()); |
| 508 | else { |
| 509 | auto mptr = _proc.modules().GetModule(mod_name); |
| 510 | if (mptr) |
| 511 | hmod = (HMODULE)mptr->baseAddress; |
| 512 | } |
| 513 | if (hmod == NULL) |
| 514 | return 0; |
| 515 | address.replace(idx1, idx2 - idx1 + 1, toUpperHex(reinterpret_cast<uintptr_t>(hmod))); |
| 516 | } |
| 517 | for (size_t i = 0; i < address.size();) { |
| 518 | if (address[i] == L'[') |
| 519 | sk.push_back(i); |
| 520 | if (address[i] == L']') { |
| 521 | idx1 = pop_back_value(sk); |
| 522 | idx2 = i; |
| 523 | auto sad = address.substr(idx1 + 1, idx2 - idx1 - 1); |
| 524 | size_t src = stringcompute(sad.data()); |
| 525 | size_t next; |
| 526 | if (!mem_read(&next, src, sizeof(size_t)) || next == 0) |
| 527 | return 0; |
| 528 | address.replace(idx1, idx2 - idx1 + 1, toUpperHex(next)); |
| 529 | i = idx1; |
| 530 | } |
| 531 | ++i; |
| 532 | } |
| 533 | if (address.find(L'[') == wstring::npos && !address_has_operator(address)) |
| 534 | return parse_hex_word(address); |
| 535 | return stringcompute(address.data()); |
| 536 | } |
| 537 | |
| 538 | void ProcessMemory::hex2bins(vector<uchar> &bin, const wstring &hex, size_t size) { |
| 539 | const wstring clean = normalize_hex(hex); |
nothing calls this directly
no test coverage detected