| 617 | |
| 618 | |
| 619 | BOOL GetPathHash(LPCWSTR path, wstring& hashstr) |
| 620 | { |
| 621 | |
| 622 | hashstr = L""; |
| 623 | |
| 624 | wstring ucpath; |
| 625 | |
| 626 | if (!touppercase(path, ucpath)) |
| 627 | return FALSE; |
| 628 | |
| 629 | size_t len = ucpath.length(); |
| 630 | |
| 631 | while (len > 3) { |
| 632 | |
| 633 | if (ucpath[len - 1] == '\\') { |
| 634 | ucpath.resize(len - 1); |
| 635 | } else { |
| 636 | break; |
| 637 | } |
| 638 | len = ucpath.length(); |
| 639 | } |
| 640 | |
| 641 | if (len < 1) |
| 642 | return FALSE; |
| 643 | |
| 644 | path = ucpath.c_str(); |
| 645 | |
| 646 | string str; |
| 647 | |
| 648 | if (!unicode_to_utf8(path, str)) |
| 649 | return FALSE; |
| 650 | |
| 651 | BYTE sum[32]; |
| 652 | |
| 653 | if (!sha256(str, sum)) |
| 654 | return FALSE; |
| 655 | |
| 656 | int i; |
| 657 | |
| 658 | // use only 128bits of the sha256 to keep registry key length shorter |
| 659 | |
| 660 | for (i = 0; i < 16; i++) { |
| 661 | WCHAR buf[3]; |
| 662 | swprintf_s(buf, L"%02x", sum[i]); |
| 663 | hashstr += buf; |
| 664 | } |
| 665 | |
| 666 | return TRUE; |
| 667 | } |
| 668 | |
| 669 | void SetOverlapped(LPOVERLAPPED pOv, LONGLONG offset) |
| 670 | { |
no test coverage detected