├── .clang-format
├── .clang_complete
├── .cmake-format.json
├── .gitignore
├── .vscode
├── c_cpp_properties.json
└── settings.json
├── AppExec
├── AppExec.manifest
├── AppExec.rc
├── CMakeLists.txt
├── app.cc
├── app.hpp
├── app.ico
├── appx.cc
├── capabilities.cc
├── main.cc
├── resource.h
└── settings.cc
├── CMakeLists.txt
├── LICENSE
├── Privexec
├── CMakeLists.txt
├── Privexec.manifest
├── Privexec.rc
├── alias.cc
├── app.cc
├── app.hpp
├── app.ico
├── capabilities.cc
├── main.cc
└── resource.h
├── ReadMe.md
├── build.ps1
├── cmake
└── modules
│ └── VersionFromVCS.cmake
├── config
└── Privexec.json
├── docs
├── Details.md
├── calist.txt
├── changelog.md
├── covert.ps1
├── images
│ ├── admin.png
│ ├── alias.png
│ ├── appcontainer.png
│ ├── appexec.png
│ ├── austack.png
│ ├── wsudo-bridge-new-mintty.png
│ ├── wsudo.png
│ └── wsudo3.png
└── useful.md
├── include
├── apphelp.hpp
├── baseversion.h
├── baseversion.h.cmake
├── capabilities.hpp
├── file.hpp
├── graphics.hpp
├── json.hpp
├── json.hpp.lock
└── vfsenv.hpp
├── lib
├── ReadMe.md
└── exec
│ ├── CMakeLists.txt
│ ├── appcontainer.cc
│ ├── appx.hpp
│ ├── argv.cc
│ ├── elevator.cc
│ ├── exec.cc
│ ├── exec.hpp
│ ├── execinternal.hpp
│ └── system.cc
├── resources
├── Square44x44Logo.altform-unplated_targetsize-32.png
└── Square44x44Logo.targetsize-32.png
├── script
├── runassys.bat
├── runassys.ps1
├── runasti.bat
├── runasti.ps1
└── uninstall.bat
├── test
├── apc
│ ├── CMakeLists.txt
│ └── edge.cc
├── appmanifest
│ ├── FluentEditor.appxmanifest
│ ├── edgeuwp.xml
│ ├── ubuntu.xml
│ └── windbg.xml
├── pugixml
│ └── main.cc
└── strappend.cc
├── tools
├── capabilities.txt
└── generate.ps1
├── vendor
├── bela.lock
├── bela
│ ├── .clang-format
│ ├── .clang_complete
│ ├── .cmake-format.json
│ ├── .gitignore
│ ├── CMakeLists.txt
│ ├── CMakeSettings.json
│ ├── LICENSE
│ ├── ReadMe.md
│ ├── build.bat
│ ├── build.ps1
│ ├── clang-tidy.bat
│ ├── clang-tidy.ps1
│ ├── compile_flags.txt
│ ├── docs
│ │ ├── ReadMe.md
│ │ ├── en-US
│ │ │ └── path.md
│ │ └── zh-CN
│ │ │ ├── ReadMe.md
│ │ │ ├── path.md
│ │ │ ├── strcat.md
│ │ │ └── strformat.md
│ ├── external
│ │ ├── charconv
│ │ │ ├── .clang-format
│ │ │ ├── VERSION
│ │ │ ├── charconv
│ │ │ ├── xcharconv.h
│ │ │ ├── xcharconv_ryu.h
│ │ │ ├── xcharconv_ryu_tables.h
│ │ │ └── xcharconv_tables.h
│ │ ├── dtoa_milo.h
│ │ ├── escapeargv.c
│ │ ├── ntimage.h
│ │ ├── ntimage.h.txt
│ │ ├── semver.hpp
│ │ ├── unicode.cc
│ │ └── unicode.hpp
│ ├── include
│ │ ├── bela
│ │ │ ├── __basal
│ │ │ │ └── basal.hpp
│ │ │ ├── __charconv
│ │ │ │ ├── tables.hpp
│ │ │ │ └── to_chars_base_10.hpp
│ │ │ ├── __format
│ │ │ │ └── args.hpp
│ │ │ ├── __phmap
│ │ │ │ ├── LICENSE
│ │ │ │ ├── VERSION
│ │ │ │ ├── btree.h
│ │ │ │ ├── meminfo.h
│ │ │ │ ├── phmap.h
│ │ │ │ ├── phmap_base.h
│ │ │ │ ├── phmap_bits.h
│ │ │ │ ├── phmap_config.h
│ │ │ │ ├── phmap_dump.h
│ │ │ │ ├── phmap_fwd_decl.h
│ │ │ │ └── phmap_utils.h
│ │ │ ├── __strings
│ │ │ │ ├── int128_have_intrinsic.inc
│ │ │ │ ├── int128_no_intrinsic.inc
│ │ │ │ ├── str_join_internal.hpp
│ │ │ │ ├── str_join_narrow_internal.hpp
│ │ │ │ ├── str_split_internal.hpp
│ │ │ │ ├── str_split_narrow_internal.hpp
│ │ │ │ └── string_cat_internal.hpp
│ │ │ ├── __unicode
│ │ │ │ └── unicode-width.hpp
│ │ │ ├── __windows
│ │ │ │ └── image.hpp
│ │ │ ├── ascii.hpp
│ │ │ ├── base.hpp
│ │ │ ├── btree.hpp
│ │ │ ├── buffer.hpp
│ │ │ ├── bufio.hpp
│ │ │ ├── bytes_view.hpp
│ │ │ ├── charconv.hpp
│ │ │ ├── city.hpp
│ │ │ ├── codecvt.hpp
│ │ │ ├── color.hpp
│ │ │ ├── comutils.hpp
│ │ │ ├── datetime.hpp
│ │ │ ├── endian.hpp
│ │ │ ├── env.hpp
│ │ │ ├── escapeargv.hpp
│ │ │ ├── escaping.hpp
│ │ │ ├── fmt.hpp
│ │ │ ├── fnmatch.hpp
│ │ │ ├── fs.hpp
│ │ │ ├── hash.hpp
│ │ │ ├── int128.hpp
│ │ │ ├── io.hpp
│ │ │ ├── macros.hpp
│ │ │ ├── match.hpp
│ │ │ ├── numbers.hpp
│ │ │ ├── os.hpp
│ │ │ ├── parseargv.hpp
│ │ │ ├── path.hpp
│ │ │ ├── pe.hpp
│ │ │ ├── phmap.hpp
│ │ │ ├── picker.hpp
│ │ │ ├── process.hpp
│ │ │ ├── repasepoint.hpp
│ │ │ ├── semver.hpp
│ │ │ ├── simulator.hpp
│ │ │ ├── static_string.hpp
│ │ │ ├── str_cat.hpp
│ │ │ ├── str_join.hpp
│ │ │ ├── str_join_narrow.hpp
│ │ │ ├── str_replace.hpp
│ │ │ ├── str_split.hpp
│ │ │ ├── str_split_narrow.hpp
│ │ │ ├── strings.hpp
│ │ │ ├── strip.hpp
│ │ │ ├── subsitute.hpp
│ │ │ ├── terminal.hpp
│ │ │ ├── time.hpp
│ │ │ ├── tokenizecmdline.hpp
│ │ │ ├── types.hpp
│ │ │ ├── und.hpp
│ │ │ ├── unicode.hpp
│ │ │ ├── utility.hpp
│ │ │ └── win32.hpp
│ │ └── hazel
│ │ │ ├── details
│ │ │ ├── DynamicTags.def
│ │ │ ├── ELFRelocs
│ │ │ │ ├── AArch64.def
│ │ │ │ ├── AMDGPU.def
│ │ │ │ ├── ARC.def
│ │ │ │ ├── ARM.def
│ │ │ │ ├── AVR.def
│ │ │ │ ├── BPF.def
│ │ │ │ ├── CSKY.def
│ │ │ │ ├── Hexagon.def
│ │ │ │ ├── Lanai.def
│ │ │ │ ├── LoongArch.def
│ │ │ │ ├── M68k.def
│ │ │ │ ├── MSP430.def
│ │ │ │ ├── Mips.def
│ │ │ │ ├── PowerPC.def
│ │ │ │ ├── PowerPC64.def
│ │ │ │ ├── RISCV.def
│ │ │ │ ├── Sparc.def
│ │ │ │ ├── SystemZ.def
│ │ │ │ ├── VE.def
│ │ │ │ ├── i386.def
│ │ │ │ └── x86_64.def
│ │ │ ├── elf.h
│ │ │ ├── macho.h
│ │ │ └── version.lock
│ │ │ ├── elf.hpp
│ │ │ ├── fs.hpp
│ │ │ ├── hazel.hpp
│ │ │ ├── macho.hpp
│ │ │ ├── types.hpp
│ │ │ └── zip.hpp
│ ├── res
│ │ ├── 1903.manifest
│ │ ├── longPathAware.manifest
│ │ ├── utf8activeCodePage.manifest
│ │ └── win10.manifest
│ ├── src
│ │ ├── bela
│ │ │ ├── CMakeLists.txt
│ │ │ ├── __charconv
│ │ │ │ ├── charconv_float.cc
│ │ │ │ ├── ryu.hpp
│ │ │ │ └── ryu_tables.hpp
│ │ │ ├── __fnmatch
│ │ │ │ ├── fnmatch.cc
│ │ │ │ └── fnmatch_internal.hpp
│ │ │ ├── __format
│ │ │ │ ├── fmt.cc
│ │ │ │ └── writer.hpp
│ │ │ ├── ascii.cc
│ │ │ ├── city.cc
│ │ │ ├── codecvt.cc
│ │ │ ├── errno.cc
│ │ │ ├── escaping.cc
│ │ │ ├── int128.cc
│ │ │ ├── match.cc
│ │ │ ├── numbers.cc
│ │ │ ├── str_cat.cc
│ │ │ ├── str_replace.cc
│ │ │ ├── str_split.cc
│ │ │ ├── str_split_narrow.cc
│ │ │ ├── subsitute.cc
│ │ │ └── terminal.cc
│ │ ├── belahash
│ │ │ ├── CMakeLists.txt
│ │ │ ├── ReadMe.md
│ │ │ ├── blake3.lock
│ │ │ ├── blake3
│ │ │ │ ├── .gitignore
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── Makefile.testing
│ │ │ │ ├── README.md
│ │ │ │ ├── blake3-config.cmake.in
│ │ │ │ ├── blake3.c
│ │ │ │ ├── blake3.h
│ │ │ │ ├── blake3_avx2.c
│ │ │ │ ├── blake3_avx2_x86-64_unix.S
│ │ │ │ ├── blake3_avx2_x86-64_windows_gnu.S
│ │ │ │ ├── blake3_avx2_x86-64_windows_msvc.asm
│ │ │ │ ├── blake3_avx512.c
│ │ │ │ ├── blake3_avx512_x86-64_unix.S
│ │ │ │ ├── blake3_avx512_x86-64_windows_gnu.S
│ │ │ │ ├── blake3_avx512_x86-64_windows_msvc.asm
│ │ │ │ ├── blake3_dispatch.c
│ │ │ │ ├── blake3_impl.h
│ │ │ │ ├── blake3_neon.c
│ │ │ │ ├── blake3_portable.c
│ │ │ │ ├── blake3_sse2.c
│ │ │ │ ├── blake3_sse2_x86-64_unix.S
│ │ │ │ ├── blake3_sse2_x86-64_windows_gnu.S
│ │ │ │ ├── blake3_sse2_x86-64_windows_msvc.asm
│ │ │ │ ├── blake3_sse41.c
│ │ │ │ ├── blake3_sse41_x86-64_unix.S
│ │ │ │ ├── blake3_sse41_x86-64_windows_gnu.S
│ │ │ │ ├── blake3_sse41_x86-64_windows_msvc.asm
│ │ │ │ ├── example.c
│ │ │ │ ├── libblake3.pc.in
│ │ │ │ ├── main.c
│ │ │ │ └── test.py
│ │ │ ├── hashinternal.hpp
│ │ │ ├── sha256-intel.cc
│ │ │ ├── sha256.cc
│ │ │ ├── sha3.cc
│ │ │ ├── sha512.cc
│ │ │ └── sm3.cc
│ │ ├── belashl
│ │ │ ├── CMakeLists.txt
│ │ │ └── picker.cc
│ │ ├── belatime
│ │ │ ├── CMakeLists.txt
│ │ │ ├── ReadMe.md
│ │ │ ├── clock.cc
│ │ │ ├── datetime.cc
│ │ │ ├── dos.cc
│ │ │ ├── duration.cc
│ │ │ ├── format.cc
│ │ │ ├── time.cc
│ │ │ └── timezone.cc
│ │ ├── belaund
│ │ │ ├── CMakeLists.txt
│ │ │ └── llvm
│ │ │ │ ├── VERSION
│ │ │ │ ├── include
│ │ │ │ └── llvm
│ │ │ │ │ └── Demangle
│ │ │ │ │ ├── Demangle.h
│ │ │ │ │ ├── DemangleConfig.h
│ │ │ │ │ ├── ItaniumDemangle.h
│ │ │ │ │ ├── ItaniumNodes.def
│ │ │ │ │ ├── MicrosoftDemangle.h
│ │ │ │ │ ├── MicrosoftDemangleNodes.h
│ │ │ │ │ ├── README.txt
│ │ │ │ │ ├── StringViewExtras.h
│ │ │ │ │ └── Utility.h
│ │ │ │ └── lib
│ │ │ │ └── Demangle
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── DLangDemangle.cpp
│ │ │ │ ├── Demangle.cpp
│ │ │ │ ├── ItaniumDemangle.cpp
│ │ │ │ ├── MicrosoftDemangle.cpp
│ │ │ │ ├── MicrosoftDemangleNodes.cpp
│ │ │ │ └── RustDemangle.cpp
│ │ ├── belawin
│ │ │ ├── CMakeLists.txt
│ │ │ ├── ReadMe.md
│ │ │ ├── env.cc
│ │ │ ├── fs.cc
│ │ │ ├── io.cc
│ │ │ ├── path.cc
│ │ │ ├── pe
│ │ │ │ ├── ReadMe.md
│ │ │ │ ├── delayimports.cc
│ │ │ │ ├── dotnet.cc
│ │ │ │ ├── exports.cc
│ │ │ │ ├── file.cc
│ │ │ │ ├── images
│ │ │ │ │ └── pe32.svg
│ │ │ │ ├── imports.cc
│ │ │ │ ├── internal.hpp
│ │ │ │ ├── overlay.cc
│ │ │ │ ├── resource.cc
│ │ │ │ ├── rva.cc
│ │ │ │ ├── searcher.cc
│ │ │ │ ├── section.cc
│ │ │ │ ├── string.cc
│ │ │ │ ├── symbol.cc
│ │ │ │ └── version.cc
│ │ │ ├── process.cc
│ │ │ ├── realpath.cc
│ │ │ └── simulator.cc
│ │ └── hazel
│ │ │ ├── CMakeLists.txt
│ │ │ ├── elf
│ │ │ ├── ReadMe.md
│ │ │ ├── dynamic.cc
│ │ │ ├── elf.cc
│ │ │ ├── gnu.cc
│ │ │ ├── images
│ │ │ │ ├── ELF_Executable_and_Linkable_Format_diagram_by_Ange_Albertini.png
│ │ │ │ └── Elf-layout.svg
│ │ │ └── symbol.cc
│ │ │ ├── fs.cc
│ │ │ ├── hazel.cc
│ │ │ ├── ina
│ │ │ ├── archive.cc
│ │ │ ├── binexeobj.cc
│ │ │ ├── docs.cc
│ │ │ ├── docs.hpp
│ │ │ ├── font.cc
│ │ │ ├── git.cc
│ │ │ ├── hazelinc.hpp
│ │ │ ├── image.cc
│ │ │ ├── media.cc
│ │ │ ├── shebang.cc
│ │ │ ├── shl.cc
│ │ │ ├── shl.hpp
│ │ │ └── text.cc
│ │ │ ├── macho
│ │ │ ├── ReadMe.md
│ │ │ ├── fat.cc
│ │ │ ├── images
│ │ │ │ ├── hello-macho.jpg
│ │ │ │ └── micro-macho.jpg
│ │ │ └── macho.cc
│ │ │ ├── mime.cc
│ │ │ └── zip
│ │ │ ├── ReadMe.md
│ │ │ ├── decompress.cc
│ │ │ ├── filemode.cc
│ │ │ ├── images
│ │ │ ├── ZIP-64_Internal_Layout.svg
│ │ │ └── winzipaes.md
│ │ │ ├── zip.cc
│ │ │ └── zipinternal.hpp
│ ├── test
│ │ ├── CMakeLists.txt
│ │ ├── appexeclink
│ │ │ ├── CMakeLists.txt
│ │ │ ├── afunix.c
│ │ │ ├── appexeclink.cc
│ │ │ ├── fv.cc
│ │ │ └── rptest.cc
│ │ ├── base
│ │ │ ├── CMakeLists.txt
│ │ │ ├── ascii.cc
│ │ │ ├── base.cc
│ │ │ ├── cityhash.cc
│ │ │ ├── constexpr_base.cc
│ │ │ ├── delfile.cc
│ │ │ ├── fnmatch.cc
│ │ │ ├── iota.cc
│ │ │ ├── startswith.cc
│ │ │ ├── static_string.cc
│ │ │ ├── strings_cat.cc
│ │ │ ├── strsplit.cc
│ │ │ └── unicodewidth.hpp
│ │ ├── binview
│ │ │ ├── CMakeLists.txt
│ │ │ ├── elfview.cc
│ │ │ └── machoview.cc
│ │ ├── color
│ │ │ ├── CMakeLists.txt
│ │ │ └── main.cc
│ │ ├── escape
│ │ │ ├── CMakeLists.txt
│ │ │ ├── escape.cc
│ │ │ └── settitle.cc
│ │ ├── escapeargv
│ │ │ ├── CMakeLists.txt
│ │ │ ├── eva.cc
│ │ │ └── evw.cc
│ │ ├── filehash
│ │ │ ├── CMakeLists.txt
│ │ │ └── filehash.cc
│ │ ├── fmt
│ │ │ ├── CMakeLists.txt
│ │ │ ├── charconv.cc
│ │ │ ├── main.cc
│ │ │ ├── strjoin.cc
│ │ │ ├── ucwidth-wt.hpp
│ │ │ ├── ucwidth.cc
│ │ │ └── unicode-width.cc
│ │ ├── hazel
│ │ │ ├── CMakeLists.txt
│ │ │ ├── shebang-gen.cc
│ │ │ └── zipview.cc
│ │ ├── io
│ │ │ ├── CMakeLists.txt
│ │ │ └── readall.cc
│ │ ├── ls
│ │ │ ├── CMakeLists.txt
│ │ │ └── main.cc
│ │ ├── mix
│ │ │ ├── CMakeLists.txt
│ │ │ └── endian.cc
│ │ ├── now
│ │ │ ├── CMakeLists.txt
│ │ │ └── now.cc
│ │ ├── semver
│ │ │ ├── CMakeLists.txt
│ │ │ └── main.cc
│ │ ├── tokencmd
│ │ │ ├── CMakeLists.txt
│ │ │ └── tokencmd.cc
│ │ ├── win
│ │ │ ├── CMakeLists.txt
│ │ │ ├── pecoff.cc
│ │ │ ├── pick.cc
│ │ │ └── version.cc
│ │ └── winutils
│ │ │ ├── CMakeLists.txt
│ │ │ ├── dirname.cc
│ │ │ ├── env2.cc
│ │ │ ├── envps.cc
│ │ │ ├── exepath.cc
│ │ │ ├── expandenv.cc
│ │ │ ├── pathcat.cc
│ │ │ ├── process.cc
│ │ │ ├── which.cc
│ │ │ └── writefile.cc
│ └── utils
│ │ ├── scanner
│ │ ├── main.cc
│ │ ├── scanner.cc
│ │ └── scanner.hpp
│ │ └── update-unicode
│ │ ├── .gitignore
│ │ └── update_unicode.sh
├── pugixml.lock
└── pugixml
│ ├── LICENSE.md
│ ├── pugiconfig.hpp
│ ├── pugixml.cpp
│ └── pugixml.hpp
└── wsudo
├── CMakeLists.txt
├── alias.cc
├── alias.hpp
├── delegate.cc
├── env.hpp
├── resource.h
├── server.cc
├── server.hpp
├── shield.ico
├── verify.md
├── wsudo-bridge.cc
├── wsudo-bridge.rc
├── wsudo-bridge.trace.cc
├── wsudo.cc
├── wsudo.hpp
├── wsudo.ico
├── wsudo.manifest
├── wsudo.rc
└── wsudo.svg
/.clang-format:
--------------------------------------------------------------------------------
1 | BasedOnStyle: LLVM
2 | SortIncludes: false
3 | ColumnLimit: 120
--------------------------------------------------------------------------------
/.clang_complete:
--------------------------------------------------------------------------------
1 | -Iinclude
2 | -Ilib/exec
3 | -Ivendor/bela/include
4 |
--------------------------------------------------------------------------------
/.cmake-format.json:
--------------------------------------------------------------------------------
1 | {
2 | "format": {
3 | "line_width": 120,
4 | "tab_size": 2,
5 | "max_pargs_hwrap": 4,
6 | "max_subgroups_hwrap": 2,
7 | "separate_ctrl_name_with_space": false,
8 | "separate_fn_name_with_space": false,
9 | "dangle_parens": false
10 | }
11 | }
--------------------------------------------------------------------------------
/.vscode/c_cpp_properties.json:
--------------------------------------------------------------------------------
1 | {
2 | "configurations": [
3 | {
4 | "name": "Win32",
5 | "includePath": [
6 | "${workspaceFolder}/**",
7 | "${workspaceFolder}/include"
8 | ],
9 | "defines": [
10 | "_DEBUG",
11 | "UNICODE",
12 | "_UNICODE"
13 | ]
14 | }
15 | ],
16 | "version": 4
17 | }
--------------------------------------------------------------------------------
/AppExec/AppExec.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 | AppExec
4 |
5 |
6 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | true/PM
27 | PerMonitorV2, PerMonitor
28 | true
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/AppExec/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # privexec
2 |
3 | add_executable(
4 | AppExec WIN32
5 | settings.cc
6 | capabilities.cc
7 | app.cc
8 | appx.cc
9 | main.cc
10 | Appexec.manifest
11 | Appexec.rc)
12 |
13 | if(PRIVEXEC_ENABLE_LTO)
14 | set_property(TARGET AppExec PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
15 | endif()
16 |
17 | target_link_libraries(
18 | AppExec
19 | Exec
20 | belashl
21 | Comctl32
22 | Shlwapi
23 | Pathcch
24 | wtsapi32
25 | Userenv
26 | Taskschd
27 | Kernel32
28 | Gdi32
29 | Advapi32)
30 |
31 | install(TARGETS AppExec DESTINATION .)
32 |
--------------------------------------------------------------------------------
/AppExec/app.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WildByDesign/AppContainer-Launcher/6f63b1e2dc9e3ddab03c0599bb7d686ec59c046a/AppExec/app.ico
--------------------------------------------------------------------------------
/AppExec/appx.cc:
--------------------------------------------------------------------------------
1 | //////// Appmanifest import
2 | // working in progress
3 | #include "app.hpp"
4 | // https://www.appveyor.com/docs/windows-images-software/#visual-studio-2017
5 | // Appveyor Visual Studio Community 2017 version 15.9.4
6 | #include
7 | #include
8 |
9 | namespace priv {
10 | bool App::ParseAppx(std::wstring_view file) {
11 | auto basename = bela::BaseName(file);
12 | title.Update(basename);
13 | std::vector caps;
14 | bela::error_code ec;
15 | if (!wsudo::exec::LoadAppx(file, caps, ec)) {
16 | return false;
17 | }
18 | auto N = ListView_GetItemCount(appx.hlview);
19 | for (int i = 0; i < N; i++) {
20 | auto p = appx.CheckedValue(i);
21 | if (std::find(caps.begin(), caps.end(), p) != caps.end()) {
22 | ListView_SetCheckState(appx.hlview, i, TRUE);
23 | } else {
24 | ListView_SetCheckState(appx.hlview, i, FALSE);
25 | }
26 | }
27 | return true;
28 | }
29 | } // namespace priv
--------------------------------------------------------------------------------
/AppExec/capabilities.cc:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include "app.hpp"
5 | #include "resource.h"
6 |
7 | namespace priv {
8 |
9 | bool IsKnownCapabilityNames(std::wstring_view name) {
10 | for (auto c : KnownCapabilityNames) {
11 | if (name == c) {
12 | return true;
13 | }
14 | }
15 | return false;
16 | }
17 |
18 | bool App::InitializeCapabilities() {
19 | ListView_SetExtendedListViewStyleEx(appx.hlview, LVS_EX_CHECKBOXES, LVS_EX_CHECKBOXES);
20 | LVCOLUMNW lvw;
21 | memset(&lvw, 0, sizeof(lvw));
22 | lvw.cx = 200;
23 | ListView_InsertColumn(appx.hlview, 0, &lvw);
24 | constexpr std::size_t wnlen = sizeof(capabilityNames) / sizeof(CapabilityName);
25 | for (std::size_t n = wnlen; n > 0; n--) {
26 | const auto &w = capabilityNames[n - 1];
27 | LVITEMW item;
28 | ZeroMemory(&item, sizeof(item));
29 | item.mask = LVIF_TEXT | LVIF_PARAM;
30 | item.pszText = const_cast(w.name);
31 | item.lParam = (LPARAM)w.value;
32 | ListView_InsertItem(appx.hlview, &item);
33 | }
34 | ListView_SetColumnWidth(appx.hlview, 0, LVSCW_AUTOSIZE_USEHEADER);
35 | return true;
36 | }
37 | } // namespace priv
--------------------------------------------------------------------------------
/AppExec/main.cc:
--------------------------------------------------------------------------------
1 | ///
2 | #include
3 | #include "app.hpp"
4 | #include
5 |
6 | int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine,
7 | _In_ int nCmdShow) {
8 | priv::dotcom_global_initializer di;
9 | priv::App app;
10 | // INITCOMMONCONTROLSEX iccex;
11 | // iccex.dwICC = ICC_WIN95_CLASSES;
12 | // iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
13 | // InitCommonControlsEx(&iccex);
14 | return app.run(hInstance);
15 | }
16 |
--------------------------------------------------------------------------------
/AppExec/resource.h:
--------------------------------------------------------------------------------
1 | ///
2 | #ifndef RESOURCE_H
3 | #define RESOURCE_H
4 | #include "baseversion.h"
5 | #define IDI_APPLICATION_ICON 101
6 | #define IDD_APPLICATION_DIALOG 102
7 |
8 | #define IDM_APPEXEC_ABOUT 1000
9 | #define IDS_APPCONTAINER_NAME 1001
10 | #define IDE_APPCONTAINER_NAME 1002
11 | #define IDC_ENABLE_LPAC 1003
12 | #define IDS_ENABLE_LPAC 1004
13 | #define IDC_COMMAND_STATIC 1005
14 | #define IDC_COMMAND_EDIT 1006
15 | #define IDB_COMMAND_TARGET 1007
16 | #define IDB_EXECUTE_BUTTON 1008
17 | #define IDB_EXIT_BUTTON 1009
18 | #define IDS_APPSTARTUP 1010
19 | #define IDE_APPSTARTUP 1011
20 | #define IDB_APPSTARTUP 1012
21 | #define IDS_APPCONTAINER_ACL 1013
22 | #define IDE_APPCONTAINER_ACL 1014
23 | #define IDS_CAPABILITIES_LIST 1015 // recommended
24 | #define IDL_APPCONTAINER_LISTVIEW 1016
25 | #define IDE_APPEXEC_INFO 1017
26 | #define IDS_HELPMSG 1018
27 | #define IDL_APPEXEC_DESC 1019
28 | #define IDM_APPTHEME 1020
29 |
30 | #define IDB_APPX_IMPORT 1021
31 |
32 | #define CS_LISTVIEW WS_BORDER | WS_VSCROLL | WS_TABSTOP | LVS_REPORT | LVS_NOCOLUMNHEADER
33 |
34 | #define CS_BASE \
35 | BS_PUSHBUTTON | BS_TEXT | BS_DEFPUSHBUTTON | BS_CHECKBOX | BS_AUTOCHECKBOX | WS_CHILD | \
36 | WS_OVERLAPPED | WS_VISIBLE
37 |
38 | #define CS_EDIT \
39 | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN | ES_LEFT | WS_VSCROLL
40 |
41 | // Next default values for new objects
42 | //
43 | #ifdef APSTUDIO_INVOKED
44 | #ifndef APSTUDIO_READONLY_SYMBOLS
45 | #define _APS_NEXT_RESOURCE_VALUE 103
46 | #define _APS_NEXT_COMMAND_VALUE 40001
47 | #define _APS_NEXT_CONTROL_VALUE 1008
48 | #define _APS_NEXT_SYMED_VALUE 101
49 | #endif
50 | #endif
51 |
52 | #endif
53 |
--------------------------------------------------------------------------------
/AppExec/settings.cc:
--------------------------------------------------------------------------------
1 | /////////////
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include "app.hpp"
10 |
11 | namespace priv {
12 | bool AppInitializeSettings(AppSettings &as) {
13 | auto file = PathSearcher::Instance().JoinAppData(LR"(Privexec\AppExec.json)");
14 | FD fd;
15 | if (_wfopen_s(&fd.fd, file.data(), L"rb") != 0) {
16 | return false;
17 | }
18 | try {
19 | auto j = nlohmann::json::parse(fd.fd, nullptr, true, true);
20 | auto root = j["AppExec"];
21 | auto bk = bela::color::decode(root["Background"].get(), bela::color(243, 243, 243));
22 | as.bk = bk;
23 | as.textcolor = calcLuminance(bk.r, bk.g, bk.b);
24 | } catch (const std::exception &e) {
25 | OutputDebugStringA(e.what());
26 | return false;
27 | }
28 | return true;
29 | }
30 |
31 | bool AppApplySettings(const AppSettings &as) {
32 | auto file = PathSearcher::Instance().JoinAppData(LR"(Privexec\AppExec.json)");
33 | std::filesystem::path p(file);
34 | auto parent = p.parent_path();
35 | std::error_code e;
36 | if (!std::filesystem::exists(parent, e)) {
37 | if (!std::filesystem::create_directories(parent, e)) {
38 | auto ec = bela::make_error_code_from_std(e);
39 | return false;
40 | }
41 | }
42 | nlohmann::json j;
43 | try {
44 | FD fd;
45 | if (_wfopen_s(&fd.fd, file.data(), L"rb") == 0) {
46 | j = nlohmann::json::parse(fd.fd, nullptr, true, true);
47 | }
48 | } catch (const std::exception &e) {
49 | OutputDebugStringA(e.what());
50 | }
51 |
52 | try {
53 | auto it = j.find("AppExec");
54 | nlohmann::json a;
55 | if (it != j.end()) {
56 | a = *it;
57 | }
58 | a["Background"] = bela::color(as.bk).encode();
59 | j["AppExec"] = a;
60 | auto buf = j.dump(4);
61 | FD fd;
62 | if (_wfopen_s(&fd.fd, file.data(), L"w+") != 0) {
63 | return false;
64 | }
65 | fwrite(buf.data(), 1, buf.size(), fd);
66 | } catch (const std::exception &e) {
67 | OutputDebugStringA(e.what());
68 | return false;
69 | }
70 | return true;
71 | }
72 |
73 | } // namespace priv
74 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright © 2022 Force Charlie
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Privexec/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # privexec
2 |
3 | add_executable(
4 | Privexec WIN32
5 | alias.cc
6 | capabilities.cc
7 | app.cc
8 | main.cc
9 | Privexec.manifest
10 | Privexec.rc)
11 |
12 | if(PRIVEXEC_ENABLE_LTO)
13 | set_property(TARGET Privexec PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
14 | endif()
15 |
16 | target_link_libraries(
17 | Privexec
18 | Exec
19 | belashl
20 | Comctl32
21 | Shlwapi
22 | Pathcch
23 | wtsapi32
24 | Userenv
25 | Taskschd
26 | Kernel32
27 | Gdi32
28 | Advapi32)
29 |
30 | install(TARGETS Privexec DESTINATION .)
31 |
--------------------------------------------------------------------------------
/Privexec/Privexec.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 | Privexec
4 |
5 |
6 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | true/PM
27 | PerMonitorV2, PerMonitor
28 | true
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/Privexec/alias.cc:
--------------------------------------------------------------------------------
1 | /////////////
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include "app.hpp"
12 |
13 | namespace priv {
14 | struct alias_item_t {
15 | std::string_view name;
16 | std::string_view desc;
17 | std::string_view target;
18 | };
19 | bool AppAliasInitializeBuilt(std::wstring_view file) {
20 | constexpr alias_item_t items[] = {
21 | {"edit-hosts", "Edit Hosts", "Notepad %windir%\\System32\\Drivers\\etc\\hosts"}, //
22 | };
23 | try {
24 | nlohmann::json j;
25 | nlohmann::json alias;
26 | for (const auto &i : items) {
27 | nlohmann::json a;
28 | a["name"] = i.name;
29 | a["description"] = i.desc;
30 | a["target"] = i.target;
31 | alias.push_back(std::move(a));
32 | }
33 | j["alias"] = alias;
34 | bela::error_code ec;
35 | std::filesystem::path p(file);
36 | auto parent = p.parent_path();
37 | if (std::error_code e; !std::filesystem::exists(parent, e)) {
38 | if (!std::filesystem::create_directories(parent, e)) {
39 | ec = bela::make_error_code_from_std(e);
40 | return false;
41 | }
42 | }
43 | if (!bela::io::AtomicWriteText(file, bela::io::as_bytes(j.dump(4)), ec)) {
44 | return false;
45 | }
46 | } catch (const std::exception &e) {
47 | OutputDebugStringA(e.what());
48 | return false;
49 | }
50 | return true;
51 | }
52 |
53 | std::wstring AppAliasFile() {
54 | //
55 | return PathSearcher::Instance().JoinAppData(LR"(Privexec\Privexec.json)");
56 | }
57 |
58 | bool AppAliasInitialize(HWND hbox, priv::alias_t &alias) {
59 | auto file = PathSearcher::Instance().JoinAppData(LR"(Privexec\Privexec.json)");
60 | if (!bela::PathExists(file)) {
61 | if (!AppAliasInitializeBuilt(file)) {
62 | return false;
63 | }
64 | }
65 | priv::FD fd;
66 | if (_wfopen_s(&fd.fd, file.data(), L"rb") != 0) {
67 | return false;
68 | }
69 | try {
70 | auto json = nlohmann::json::parse(fd.fd, nullptr, true, true);
71 | auto cmds = json["alias"];
72 | for (auto &cmd : cmds) {
73 | auto desc = bela::encode_into(cmd["description"].get());
74 | alias.insert_or_assign(desc, bela::encode_into(cmd["target"].get()));
75 | ::SendMessageW(hbox, CB_ADDSTRING, 0, (LPARAM)desc.data());
76 | }
77 | } catch (const std::exception &e) {
78 | OutputDebugStringA(e.what());
79 | return false;
80 | }
81 | return true;
82 | }
83 | } // namespace priv
84 |
--------------------------------------------------------------------------------
/Privexec/app.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WildByDesign/AppContainer-Launcher/6f63b1e2dc9e3ddab03c0599bb7d686ec59c046a/Privexec/app.ico
--------------------------------------------------------------------------------
/Privexec/capabilities.cc:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include "app.hpp"
4 | #include "resource.h"
5 | #include
6 |
7 | /// SEE:
8 | /// https://github.com/googleprojectzero/sandbox-attacksurface-analysis-tools/blob/main/NtApiDotNet/SecurityCapabilities.cs
9 | // $source=Get-Content -Path .\SecurityCapabilities.cs -Raw
10 | // Add-Type -TypeDefinition $source
11 |
12 | namespace priv {
13 | bool IsKnownCapabilityNames(std::wstring_view name) {
14 | for (auto c : KnownCapabilityNames) {
15 | if (name == c) {
16 | return true;
17 | }
18 | }
19 | return false;
20 | }
21 |
22 | bool App::InitializeCapabilities() {
23 | capabilities.hlview = GetDlgItem(hWnd, IDL_APPCONTAINER_LISTVIEW);
24 | capabilities.hlpacbox = GetDlgItem(hWnd, IDC_LPACMODE);
25 | ListView_SetExtendedListViewStyleEx(capabilities.hlview, LVS_EX_CHECKBOXES, LVS_EX_CHECKBOXES);
26 | LVCOLUMNW lvw;
27 | memset(&lvw, 0, sizeof(lvw));
28 | lvw.cx = 200;
29 | ListView_InsertColumn(capabilities.hlview, 0, &lvw);
30 | constexpr std::size_t wnlen = sizeof(capabilityNames) / sizeof(CapabilityName);
31 | for (std::size_t n = wnlen; n > 0; n--) {
32 | const auto &w = capabilityNames[n - 1];
33 | LVITEMW item;
34 | ZeroMemory(&item, sizeof(item));
35 | item.mask = LVIF_TEXT | LVIF_PARAM;
36 | item.pszText = const_cast(w.name);
37 | item.lParam = (LPARAM)w.value;
38 | ListView_InsertItem(capabilities.hlview, &item);
39 | }
40 | ListView_SetColumnWidth(capabilities.hlview, 0, LVSCW_AUTOSIZE_USEHEADER);
41 | return true;
42 | }
43 | } // namespace priv
--------------------------------------------------------------------------------
/Privexec/main.cc:
--------------------------------------------------------------------------------
1 | ///
2 | #include
3 | #include "app.hpp"
4 | #include
5 |
6 | int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine,
7 | _In_ int nCmdShow) {
8 | priv::dotcom_global_initializer di;
9 | priv::App app;
10 | return app.run(hInstance);
11 | }
12 |
--------------------------------------------------------------------------------
/Privexec/resource.h:
--------------------------------------------------------------------------------
1 | #ifndef RESOURCE_H
2 | #define RESOURCE_H
3 | #include "baseversion.h"
4 | #define IDI_APPLICATION_ICON 101
5 | #define IDD_APPLICATION_DIALOG 102
6 |
7 | #define IDM_PRIVEXEC_ABOUT 500
8 | #define IDM_EDIT_ALIASFILE 501
9 |
10 | #define IDC_USER_COMBOX 1001
11 | #define IDC_USER_STATIC 1002
12 | #define IDC_COMMAND_STATIC 1003
13 | #define IDC_COMMAND_COMBOX 1005
14 | #define IDB_COMMAND_TARGET 1006
15 | #define IDB_EXECUTE_BUTTON 1007
16 | #define IDB_EXIT_BUTTON 1008
17 | #define IDS_APPSTARTUP 1009
18 | #define IDE_APPSTARTUP 1010
19 | #define IDB_APPSTARTUP 1011
20 | #define IDC_COMMAND_SID 1012
21 | #define IDE_APPCONTAINER_APPMANIFEST 1013
22 | #define IDC_APPCONTAINER_STATIC 1014
23 | #define IDB_APPCONTAINER_BUTTON 1015
24 | #define IDS_RECOMMENDED_CAPS 1016 // recommended
25 | #define IDL_APPCONTAINER_LISTVIEW 1017
26 | #define IDS_HELPMSG 1018
27 | #define IDC_LPACMODE 1019
28 | #define IDM_PRIVEXEC_THEME 1020
29 |
30 | #define CS_LISTVIEW WS_BORDER | WS_VSCROLL | WS_TABSTOP | LVS_REPORT | LVS_NOCOLUMNHEADER
31 |
32 | #define CS_BASE \
33 | BS_PUSHBUTTON | BS_TEXT | BS_DEFPUSHBUTTON | BS_CHECKBOX | BS_AUTOCHECKBOX | WS_CHILD | WS_OVERLAPPED | WS_VISIBLE
34 |
35 | // Next default values for new objects
36 | //
37 | #ifdef APSTUDIO_INVOKED
38 | #ifndef APSTUDIO_READONLY_SYMBOLS
39 | #define _APS_NEXT_RESOURCE_VALUE 103
40 | #define _APS_NEXT_COMMAND_VALUE 40001
41 | #define _APS_NEXT_CONTROL_VALUE 1008
42 | #define _APS_NEXT_SYMED_VALUE 101
43 | #endif
44 | #endif
45 |
46 | #endif
47 |
--------------------------------------------------------------------------------
/ReadMe.md:
--------------------------------------------------------------------------------
1 | # AppContainer Launcher
2 | ## AppContainer and LPAC (Less Privileged AppContainer) Launcher with Capabilities
3 |
4 |
5 | ### Download:
6 |
7 | [Latest Release](https://github.com/WildByDesign/AppContainer-Launcher/releases/latest)
8 |
9 |
10 | ### Screenshot:
11 | 
12 | 
13 |
14 |
15 | ### Dark Mode or Light Mode:
16 |
17 | This program does not automatically switch between Dark Mode and Light Mode. I have compiled it as Dark Mode. However, you can manually change it to Light Mode or any other color of the rainbow.
18 |
19 | Just open the system menu and click on Change Panel Color like below:
20 |
21 | 
22 |
23 |
24 |
25 | All credit goes to Force Charlie (https://github.com/fcharlie)
26 |
27 | Original Privexec: https://github.com/M2Team/Privexec
28 |
29 |
30 | ## LPAC (Less Privileged AppContainer) Details:
31 |
32 | ### Important Capabilities for LPAC (minimum)
33 |
34 | - lpacCom
35 | - lpacAppExperience
36 | - registryRead
37 |
38 |
39 | ### Identifying LPAC Processes
40 |
41 | System Informer (previously Process Hacker) latest Nightly builds can identify LPAC as well. On the Token tab, go to Advanced to bring up the Token Properties and go to the Container tab. Capabilities tab has important details as well.
42 |
43 |
44 | ## LICENSE
45 |
46 | This project use MIT License, and JSON use [https://github.com/nlohmann/json](https://github.com/nlohmann/json) , some API use NSudo, but rewrite it.
47 |
--------------------------------------------------------------------------------
/config/Privexec.json:
--------------------------------------------------------------------------------
1 | {
2 | "alias": [
3 | {
4 | "description": "Edit Hosts",
5 | "name": "edit-hosts",
6 | "target": "Notepad %windir%\\System32\\Drivers\\etc\\hosts"
7 | },
8 | {
9 | "description": "Windows Debugger",
10 | "name": "windbg",
11 | "target": "\"%ProgramFiles(x86)%\\Windows Kits\\10\\Debuggers\\x64\\windbg.exe\""
12 | }
13 | ]
14 | }
--------------------------------------------------------------------------------
/docs/Details.md:
--------------------------------------------------------------------------------
1 | # Details
2 |
3 | `CreateProcessAsUser` Stack:
4 |
5 | 
6 |
--------------------------------------------------------------------------------
/docs/changelog.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## 2018-12-28
4 |
5 | 1. Privexec/WSUDO support `Less Privileged AppContainer`
6 | 2. Privexec AppContainer supports more capabilities to choose from
7 |
8 | ## 2018-12-22
9 |
10 | 1. Privexec (GUI) AppContainer support Restricted Capabilities.
11 | `Recommended Capabilities` can be selected at the same time as `Appmanifest`, the `Capabilities `will be merged
12 | 2. Privexec (GUI) Support Dropfiles. Appx edit box accept `*.xml;*.appmanifest` if it is activated. Command edit box accept other files.
13 |
14 | ## 2022-07-22
15 |
16 | 1. wsudo -U will create a process without privilege escalation. If it is currently running under the System account, wsudo -U cannot start the Store App directly, but it can start the Store App in the launched shell.(在系统权限下,wsudo -U 无法直接启动 Store App,但是可以在启动的 shell 中启动 Store App。)
17 | 2. wsudo add -B --basic as default (permission inheritance mode)(wsudo 添加 `-B` `--basic` 作为默认执行模式,即继承父进程权限,而 -U 则总是启动未提权的进程。)
--------------------------------------------------------------------------------
/docs/covert.ps1:
--------------------------------------------------------------------------------
1 | Get-Content $PSScriptRoot\calist.txt|ForEach-Object {
2 | $nl = $_.TrimStart()
3 | "L$nl"|Out-File -Append catemp.cc
4 | }
--------------------------------------------------------------------------------
/docs/images/admin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WildByDesign/AppContainer-Launcher/6f63b1e2dc9e3ddab03c0599bb7d686ec59c046a/docs/images/admin.png
--------------------------------------------------------------------------------
/docs/images/alias.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WildByDesign/AppContainer-Launcher/6f63b1e2dc9e3ddab03c0599bb7d686ec59c046a/docs/images/alias.png
--------------------------------------------------------------------------------
/docs/images/appcontainer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WildByDesign/AppContainer-Launcher/6f63b1e2dc9e3ddab03c0599bb7d686ec59c046a/docs/images/appcontainer.png
--------------------------------------------------------------------------------
/docs/images/appexec.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WildByDesign/AppContainer-Launcher/6f63b1e2dc9e3ddab03c0599bb7d686ec59c046a/docs/images/appexec.png
--------------------------------------------------------------------------------
/docs/images/austack.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WildByDesign/AppContainer-Launcher/6f63b1e2dc9e3ddab03c0599bb7d686ec59c046a/docs/images/austack.png
--------------------------------------------------------------------------------
/docs/images/wsudo-bridge-new-mintty.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WildByDesign/AppContainer-Launcher/6f63b1e2dc9e3ddab03c0599bb7d686ec59c046a/docs/images/wsudo-bridge-new-mintty.png
--------------------------------------------------------------------------------
/docs/images/wsudo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WildByDesign/AppContainer-Launcher/6f63b1e2dc9e3ddab03c0599bb7d686ec59c046a/docs/images/wsudo.png
--------------------------------------------------------------------------------
/docs/images/wsudo3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WildByDesign/AppContainer-Launcher/6f63b1e2dc9e3ddab03c0599bb7d686ec59c046a/docs/images/wsudo3.png
--------------------------------------------------------------------------------
/docs/useful.md:
--------------------------------------------------------------------------------
1 | # Useful docs
2 |
3 |
4 | ## Process
5 |
6 | [Reading another process’s environment](https://blogs.msdn.microsoft.com/matt_pietrek/2004/08/25/reading-another-processs-environment/ )
7 |
8 | ## Sudo internal
9 |
10 | [Comments about Windows sudo @fcharlie](https://github.com/microsoft/terminal/issues/146#issuecomment-515812461)
11 |
12 | ## Privexec Internal
13 |
14 | [Privexec New](https://forcemz.net/windows/2018/12/01/PrivexecNew/)
--------------------------------------------------------------------------------
/include/apphelp.hpp:
--------------------------------------------------------------------------------
1 | ////////////
2 | #ifndef PRIV_APPHELP_HPP
3 | #define PRIV_APPHELP_HPP
4 | #include
5 | #include
6 | #include
7 |
8 | namespace priv {
9 | class dotcom_global_initializer {
10 | public:
11 | dotcom_global_initializer() {
12 | auto hr = CoInitialize(NULL);
13 | if (FAILED(hr)) {
14 | bela::FPrintF(stderr, L"\x1b[31minitialize dotcom error: 0x%08x\x1b[0m\n", hr);
15 | exit(1);
16 | }
17 | }
18 | ~dotcom_global_initializer() { CoUninitialize(); }
19 | };
20 |
21 | } // namespace priv
22 |
23 | #endif
--------------------------------------------------------------------------------
/include/baseversion.h:
--------------------------------------------------------------------------------
1 | #ifndef PRIVEXEC_VERSION_H
2 | #define PRIVEXEC_VERSION_H
3 |
4 | #define PRIVEXEC_VERSION_MAJOR 2
5 | #define PRIVEXEC_VERSION_MINOR 6
6 | #define PRIVEXEC_VERSION_PATCH 1
7 | #define PRIVEXEC_VERSION_BUILD 0
8 |
9 | #define PRIVEXEC_VERSION L"2.6.1"
10 | #define PRIVEXEC_REVISION L"323ae224ca6272af7be64f507a2346f9a69ec619"
11 | #define PRIVEXEC_REFNAME L"refs/heads/master"
12 | #define PRIVEXEC_BUILD_TIME L"none"
13 | #define PRIVEXEC_REMOTE_URL L"git@github.com:M2Team/Privexec.git"
14 |
15 | #define PRIVEXEC_APPLINK \
16 | L"For more information about this tool. \nVisit: Privexec\nVisit: forcemz.net"
19 |
20 | #define PRIVEXEC_APPLINKE \
21 | L"Ask for help with this issue. \nVisit: Privexec " \
23 | L"Issues"
24 |
25 | #define PRIVEXEC_APPVERSION L"Version: 2.6.1\nCopyright \xA9 2022, Privexec contributors."
26 |
27 | #define PRIVEXECUI_COPYRIGHT L"Copyright \xA9 2022, Privexec contributors."
28 |
29 | #endif
30 |
--------------------------------------------------------------------------------
/include/baseversion.h.cmake:
--------------------------------------------------------------------------------
1 | // Generate code by cmake, don't modify
2 | #ifndef PRIVEXEC_VERSION_H
3 | #define PRIVEXEC_VERSION_H
4 |
5 | #define PRIVEXEC_VERSION_MAJOR ${PRIVEXEC_VERSION_MAJOR}
6 | #define PRIVEXEC_VERSION_MINOR ${PRIVEXEC_VERSION_MINOR}
7 | #define PRIVEXEC_VERSION_PATCH ${PRIVEXEC_VERSION_PATCH}
8 | #define PRIVEXEC_VERSION_BUILD 0
9 |
10 | #define PRIVEXEC_VERSION L"${PRIVEXEC_VERSION_MAJOR}.${PRIVEXEC_VERSION_MINOR}.${PRIVEXEC_VERSION_PATCH}"
11 | #define PRIVEXEC_REVISION L"${PRIVEXEC_REVISION}"
12 | #define PRIVEXEC_REFNAME L"${PRIVEXEC_REFNAME}"
13 | #define PRIVEXEC_BUILD_TIME L"${PRIVEXEC_BUILD_TIME}"
14 | #define PRIVEXEC_REMOTE_URL L"${PRIVEXEC_REMOTE_URL}"
15 |
16 | #define PRIVEXEC_APPLINK \
17 | L"For more information about this tool. \nVisit: Privexec" \
19 | L"a>\nVisit: forcemz.net"
21 |
22 | #define PRIVEXEC_APPLINKE \
23 | L"Ask for help with this issue. \nVisit: Privexec " \
25 | L"Issues"
26 |
27 | #define PRIVEXEC_APPVERSION \
28 | L"Version: ${PRIVEXEC_VERSION_MAJOR}.${PRIVEXEC_VERSION_MINOR}.${PRIVEXEC_VERSION_PATCH}\nCopyright " \
29 | L"\xA9 ${PRIVEXEC_COPYRIGHT_YEAR}, Privexec contributors."
30 |
31 | #define PRIVEXECUI_COPYRIGHT L"Copyright \xA9 ${PRIVEXEC_COPYRIGHT_YEAR}, Privexec contributors."
32 |
33 | #endif
34 |
--------------------------------------------------------------------------------
/include/file.hpp:
--------------------------------------------------------------------------------
1 | ////////////
2 | #ifndef PRIVEXEC_FILE_HPP
3 | #define PRIVEXEC_FILE_HPP
4 | #include
5 | #include
6 | #include
7 |
8 | namespace priv {
9 | struct FD {
10 | FD() = default;
11 | FD(FILE *fd_) : fd(fd_) {}
12 | FD(FD &&other) {
13 | if (fd != nullptr) {
14 | fclose(fd);
15 | }
16 | fd = other.fd;
17 | other.fd = nullptr;
18 | }
19 | FD &operator=(FD &&other) {
20 | if (fd != nullptr) {
21 | fclose(fd);
22 | }
23 | fd = other.fd;
24 | other.fd = nullptr;
25 | return *this;
26 | }
27 | FD &operator=(FILE *f) {
28 | if (fd != nullptr) {
29 | fclose(fd);
30 | }
31 | fd = f;
32 | return *this;
33 | }
34 | FD(const FD &) = delete;
35 | FD &operator=(const FD &) = delete;
36 | ~FD() {
37 | if (fd != nullptr) {
38 | fclose(fd);
39 | }
40 | }
41 |
42 | explicit operator bool() const noexcept { return fd != nullptr; }
43 | operator FILE *() const { return fd; }
44 | FILE *fd{nullptr};
45 | };
46 | } // namespace priv
47 |
48 | #endif
--------------------------------------------------------------------------------
/include/json.hpp.lock:
--------------------------------------------------------------------------------
1 | https://github.com/nlohmann/json
2 | version=3.11.2
3 |
--------------------------------------------------------------------------------
/lib/ReadMe.md:
--------------------------------------------------------------------------------
1 | # Privexec libs
--------------------------------------------------------------------------------
/lib/exec/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # exec lib
2 | add_library(Exec STATIC
3 | appcontainer.cc
4 | argv.cc
5 | elevator.cc
6 | exec.cc
7 | system.cc
8 | )
9 |
10 | target_link_libraries(Exec
11 | belawin
12 | )
13 |
--------------------------------------------------------------------------------
/lib/exec/appx.hpp:
--------------------------------------------------------------------------------
1 | ///
2 | #ifndef WSUDO_EXEC_APPX_HPP
3 | #define WSUDO_EXEC_APPX_HPP
4 | #include
5 |
6 | namespace wsudo::exec {
7 | bool LoadAppx(std::wstring_view file, std::vector &caps, bela::error_code &ec);
8 | }
9 |
10 | #endif
--------------------------------------------------------------------------------
/lib/exec/argv.cc:
--------------------------------------------------------------------------------
1 | // argv feature
2 | #include "exec.hpp"
3 | #include
4 | #include
5 |
6 | namespace wsudo::exec {
7 | //
8 | bool SplitArgv(std::wstring_view cmd, std::wstring &path, std::vector &argv, bela::error_code &ec) {
9 | bela::Tokenizer tokenizer;
10 | if (!tokenizer.Tokenize(cmd)) {
11 | ec = bela::make_error_code(1, L"bad command '", cmd, L"'");
12 | return false;
13 | }
14 | const auto Argv = tokenizer.Argv();
15 | const auto Argc = tokenizer.Argc();
16 | for (size_t i = 0; i < Argc; i++) {
17 | argv.emplace_back(Argv[i]);
18 | }
19 | if (argv.empty()) {
20 | ec = bela::make_error_code(1, L"bad command '", cmd, L"'");
21 | return false;
22 | }
23 | std::wstring_view arg0 = path.empty() ? argv[0] : path;
24 | std::wstring p;
25 | if (!bela::env::LookPath(arg0, p, true)) {
26 | ec = bela::make_error_code(1, L"command not found '", arg0, L"'");
27 | return false;
28 | }
29 | path.assign(std::move(p));
30 | return true;
31 | }
32 |
33 | } // namespace wsudo::exec
34 |
--------------------------------------------------------------------------------
/lib/exec/exec.hpp:
--------------------------------------------------------------------------------
1 | // exec library new command feature
2 | #ifndef WSUDO_EXEC_HPP
3 | #define WSUDO_EXEC_HPP
4 | #include
5 |
6 | namespace wsudo::exec {
7 | constexpr const wchar_t *string_nullable(std::wstring_view str) { return str.empty() ? nullptr : str.data(); }
8 | constexpr wchar_t *string_nullable(std::wstring &str) { return str.empty() ? nullptr : str.data(); }
9 |
10 | enum class privilege_t : uint8_t {
11 | none,
12 | appcontainer,
13 | mic,
14 | basic,
15 | standard,
16 | elevated, // such as administrator
17 | system,
18 | trustedinstaller,
19 | };
20 |
21 | enum class visible_t : uint8_t {
22 | none,
23 | newconsole,
24 | hide,
25 | };
26 |
27 | // command define
28 | struct command {
29 | std::wstring path;
30 | std::wstring cwd;
31 | std::wstring env;
32 | std::vector argv;
33 | uint32_t pid{0};
34 | privilege_t priv{privilege_t::standard};
35 | visible_t visible;
36 | bool execute(bela::error_code &ec);
37 | };
38 |
39 | struct appcommand {
40 | std::wstring path;
41 | std::wstring cwd;
42 | std::wstring appid;
43 | std::wstring appmanifest;
44 | std::wstring sid;
45 | std::wstring folder;
46 | std::wstring env;
47 | std::vector argv;
48 | std::vector allowdirs;
49 | std::vector regdirs;
50 | std::vector caps;
51 | visible_t visible;
52 | uint32_t pid{0};
53 | bool islpac{false};
54 | bool initialize(bela::error_code &ec);
55 | bool execute(bela::error_code &ec);
56 | };
57 |
58 | inline bool IsUserAdministratorsGroup() {
59 | SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
60 | PSID AdministratorsGroup;
61 | if (!AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0,
62 | &AdministratorsGroup)) {
63 | return false;
64 | }
65 | BOOL b = FALSE;
66 | if (!CheckTokenMembership(NULL, AdministratorsGroup, &b)) {
67 | b = FALSE;
68 | }
69 | FreeSid(AdministratorsGroup);
70 | return b == TRUE;
71 | }
72 |
73 | bool SplitArgv(std::wstring_view cmd, std::wstring &path, std::vector &argv, bela::error_code &ec);
74 | } // namespace wsudo::exec
75 |
76 | #endif
--------------------------------------------------------------------------------
/lib/exec/execinternal.hpp:
--------------------------------------------------------------------------------
1 | ///
2 | #ifndef WSUDO_EXE_INTERNAL_HPP
3 | #define WSUDO_EXE_INTERNAL_HPP
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include "exec.hpp"
11 |
12 | namespace wsudo::exec {
13 |
14 | inline void FreeToken(HANDLE &hToken) {
15 | if (hToken != INVALID_HANDLE_VALUE) {
16 | CloseHandle(hToken);
17 | hToken = INVALID_HANDLE_VALUE;
18 | }
19 | }
20 | struct privilege_entries {
21 | template privilege_entries(Args... a) { entries = std::initializer_list{a...}; }
22 | std::vector entries;
23 | std::wstring format() const {
24 | auto sz = entries.size();
25 | std::wstring s = L"[";
26 | for (size_t i = 0; i < sz; i++) {
27 | bela::StrAppend(&s, L"\"", entries[i], L"\"");
28 | if (i != sz - 1) {
29 | bela::StrAppend(&s, L", ");
30 | }
31 | }
32 | bela::StrAppend(&s, L"]");
33 | return s;
34 | }
35 | };
36 |
37 | bool GetCurrentSessionToken(PHANDLE hNewToken, bela::error_code &ec);
38 | bool GetCurrentSessionId(DWORD &dwSessionId);
39 |
40 | // System process elavator
41 | class Elavator {
42 | public:
43 | Elavator() = default;
44 | Elavator(const Elavator &) = delete;
45 | Elavator &operator=(const Elavator &) = delete;
46 | ~Elavator() { FreeToken(hToken); }
47 | // System Process PID
48 | DWORD SystemPID() const { return systemProcessId; }
49 | // Session ID
50 | DWORD SessionID() const { return currentSessionId; }
51 | bool ImpersonationSystemPrivilege(const privilege_entries *pv, bela::error_code &ec);
52 |
53 | private:
54 | bool impersonation_system_token(bela::error_code &ec);
55 | HANDLE hToken{nullptr};
56 | DWORD currentSessionId{0};
57 | // system process id
58 | DWORD systemProcessId{0};
59 | };
60 | bool execute_basic(command &cmd, bela::error_code &ec);
61 | bool execute_with_ti(command &cmd, bela::error_code &ec);
62 | bool execute_with_system(command &cmd, bela::error_code &ec);
63 | bool execute_with_token(command &cmd, HANDLE hToken, bool desktop, LPVOID lpEnvironment, bela::error_code &ec);
64 | } // namespace wsudo::exec
65 |
66 | #endif
--------------------------------------------------------------------------------
/resources/Square44x44Logo.altform-unplated_targetsize-32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WildByDesign/AppContainer-Launcher/6f63b1e2dc9e3ddab03c0599bb7d686ec59c046a/resources/Square44x44Logo.altform-unplated_targetsize-32.png
--------------------------------------------------------------------------------
/resources/Square44x44Logo.targetsize-32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WildByDesign/AppContainer-Launcher/6f63b1e2dc9e3ddab03c0599bb7d686ec59c046a/resources/Square44x44Logo.targetsize-32.png
--------------------------------------------------------------------------------
/script/runassys.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | where pwsh.exe >nul 2>nul
3 | if %ERRORLEVEL% NEQ 0 (
4 | echo It is recommended to install PowerShell 7^+ for a better experience.
5 | powershell -NoProfile -NoLogo -ExecutionPolicy unrestricted -File "%~dp0runassys.ps1" %*
6 | ) else (
7 | pwsh -NoProfile -NoLogo -ExecutionPolicy unrestricted -File "%~dp0runassys.ps1" %*
8 | )
--------------------------------------------------------------------------------
/script/runassys.ps1:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pwsh
2 | $PrivexeRoot = Split-Path -Parent $PSScriptRoot
3 |
4 | $WSudoExe = Join-Path -Path $PrivexeRoot -ChildPath "wsudo.exe"
5 | $WSudoBridge = Join-Path -Path $PrivexeRoot -ChildPath "wsudo-bridge.exe"
6 |
7 | if (!(Test-Path $WSudoExe)) {
8 | Write-Host -ForegroundColor Red "$WSudoExe not exists"
9 | Exit 1
10 | }
11 |
12 | if (!(Test-Path $WSudoBridge)) {
13 | Write-Host -ForegroundColor Red "$WSudoBridge not exists"
14 | Exit 1
15 | }
16 |
17 | $subKeys = @( 'exefile\shell\runassystem', 'batfile\shell\runassystem', 'cmdfile\shell\runassystem' )
18 |
19 |
20 | # https://powershell.org/forums/topic/cant-set-new-itemproperty-to-registry-path-containing-astrix/
21 |
22 | $hive = [Microsoft.Win32.RegistryKey]::OpenBaseKey('ClassesRoot', 'Default')
23 | foreach ($sk in $subKeys) {
24 | $subKey = $hive.CreateSubKey($sk, $true)
25 | $subkey.SetValue($null, 'Run as System', 'String')
26 | $subkey.SetValue('Icon', $WSudoBridge, 'String')
27 | $subKey = $subKey.CreateSubKey('command', $true)
28 | $subkey.SetValue($null, "`"$WSudoExe`" -S `"%1`"", 'String')
29 | }
30 |
31 |
32 |
--------------------------------------------------------------------------------
/script/runasti.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | where pwsh.exe >nul 2>nul
3 | if %ERRORLEVEL% NEQ 0 (
4 | echo It is recommended to install PowerShell 7^+ for a better experience.
5 | powershell -NoProfile -NoLogo -ExecutionPolicy unrestricted -File "%~dp0runasti.ps1" %*
6 | ) else (
7 | pwsh -NoProfile -NoLogo -ExecutionPolicy unrestricted -File "%~dp0runasti.ps1" %*
8 | )
--------------------------------------------------------------------------------
/script/runasti.ps1:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pwsh
2 | $PrivexeRoot = Split-Path -Parent $PSScriptRoot
3 | $WSudoExe = Join-Path -Path $PrivexeRoot -ChildPath "wsudo.exe"
4 | $WSudoBridge = Join-Path -Path $PrivexeRoot -ChildPath "wsudo-bridge.exe"
5 |
6 | if (!(Test-Path $WSudoExe)) {
7 | Write-Host -ForegroundColor Red "$WSudoExe not exists"
8 | Exit 1
9 | }
10 |
11 | if (!(Test-Path $WSudoBridge)) {
12 | Write-Host -ForegroundColor Red "$WSudoBridge not exists"
13 | Exit 1
14 | }
15 |
16 | $subKeys = @( 'exefile\shell\runastrustedinstaller', 'batfile\shell\runastrustedinstaller', 'cmdfile\shell\runastrustedinstaller' )
17 |
18 |
19 | # https://powershell.org/forums/topic/cant-set-new-itemproperty-to-registry-path-containing-astrix/
20 |
21 | $hive = [Microsoft.Win32.RegistryKey]::OpenBaseKey('ClassesRoot', 'Default')
22 | foreach ($sk in $subKeys) {
23 | $subKey = $hive.CreateSubKey($sk, $true)
24 | $subkey.SetValue($null, 'Run as TrustedInstaller', 'String')
25 | $subkey.SetValue('Icon', $WSudoBridge, 'String')
26 | $subKey = $subKey.CreateSubKey('command', $true)
27 | $subkey.SetValue($null, "`"$WSudoExe`" -T `"%1`"", 'String')
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/script/uninstall.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 |
3 | reg delete "HKCR\exefile\shell\runassystem" /f
4 | reg delete "HKCR\batfile\shell\runassystem" /f
5 | reg delete "HKCR\cmdfile\shell\runassystem" /f
6 | reg delete "HKCR\exefile\shell\runastrustedinstaller" /f
7 | reg delete "HKCR\batfile\shell\runastrustedinstaller" /f
8 | reg delete "HKCR\cmdfile\shell\runastrustedinstaller" /f
--------------------------------------------------------------------------------
/test/apc/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # privexec
2 |
3 | add_executable(edge_test
4 | edge.cc
5 | )
6 |
7 | target_link_libraries(edge_test
8 | bela
9 | belawin
10 | )
11 |
12 |
--------------------------------------------------------------------------------
/test/appmanifest/FluentEditor.appxmanifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | FluentThemeEditor
7 | Microsoft
8 | Assets\ColorAlgorithmToolStoreLogo.png
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/test/pugixml/main.cc:
--------------------------------------------------------------------------------
1 | ///
2 | #include
3 | #include
4 | #define PUGIXML_HEADER_ONLY 1
5 | #include "../../vendor/pugixml/pugixml.hpp"
6 |
7 | int main(int argc, char const *argv[]) {
8 | if (argc < 2) {
9 | fprintf(stderr, "usage: %s appmanifest\n", argv[0]);
10 | return 1;
11 | }
12 | pugi::xml_document doc;
13 | if (!doc.load_file(argv[1])) {
14 | fprintf(stderr, "unable load %s %s\n", argv[1], strerror(errno));
15 | return 1;
16 | }
17 | // constexpr std::string_view caps = "Capability";
18 | for (auto it : doc.child("Package").child("Capabilities")) {
19 | /* code */
20 | fprintf(stderr, "%s %s\n", it.name(), it.attribute("Name").as_string());
21 | }
22 | return 0;
23 | }
24 |
--------------------------------------------------------------------------------
/test/strappend.cc:
--------------------------------------------------------------------------------
1 | #include "../include/strcat.hpp"
2 | #include
3 | #include
4 |
5 | int wmain(int argc, wchar_t const *argv[]) {
6 | /* code */
7 | _wsetlocale(LC_ALL, L"");
8 | std::wstring s = L"nihao";
9 | base::StrAppend(&s, L" current command args: ", argc, L" first: ", argv[0]);
10 | if (argc >= 2) {
11 | base::StrAppend(&s, L" second: ", argv[1]);
12 | }
13 | wprintf(L"%s\n", s.data());
14 | return 0;
15 | }
--------------------------------------------------------------------------------
/vendor/bela.lock:
--------------------------------------------------------------------------------
1 | https://github.com/fcharlie/bela/tree/47836da3a358265302f6618180ae6c83aedfca10
2 |
--------------------------------------------------------------------------------
/vendor/bela/.clang-format:
--------------------------------------------------------------------------------
1 | BasedOnStyle: LLVM
2 | SortIncludes: false
3 | ColumnLimit: 120
4 |
--------------------------------------------------------------------------------
/vendor/bela/.clang_complete:
--------------------------------------------------------------------------------
1 | -Iinclude
2 |
--------------------------------------------------------------------------------
/vendor/bela/.cmake-format.json:
--------------------------------------------------------------------------------
1 | {
2 | "format": {
3 | "line_width": 120,
4 | "tab_size": 2,
5 | "max_pargs_hwrap": 4,
6 | "max_subgroups_hwrap": 2,
7 | "separate_ctrl_name_with_space": false,
8 | "separate_fn_name_with_space": false,
9 | "dangle_parens": false
10 | }
11 | }
--------------------------------------------------------------------------------
/vendor/bela/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | bld/
21 | [Bb]in/
22 | [Oo]bj/
23 | [Ll]og/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 |
31 | *_i.c
32 | *_p.c
33 | *_i.h
34 | *.ilk
35 | *.meta
36 | *.obj
37 | *.exe
38 | *.pch
39 | *.pdb
40 | *.pgc
41 | *.pgd
42 | *.rsp
43 | *.sbr
44 | *.tlb
45 | *.tli
46 | *.tlh
47 | *.tmp
48 | *.tmp_proj
49 | *.log
50 | *.vspscc
51 | *.vssscc
52 | .builds
53 | *.pidb
54 | *.svclog
55 | *.scc
56 | *.out
57 |
58 |
59 | # Visual C++ cache files
60 | ipch/
61 | *.aps
62 | *.ncb
63 | *.opendb
64 | *.opensdf
65 | *.sdf
66 | *.cachefile
67 | *.VC.db
68 | *.VC.VC.opendb
69 |
70 |
71 | build/
72 | dist/
73 | /.vscode/
--------------------------------------------------------------------------------
/vendor/bela/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # bela sources
2 | cmake_minimum_required(VERSION 3.22)
3 |
4 | project(bela CXX C ASM)
5 |
6 | if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE)
7 | message(
8 | FATAL_ERROR
9 | "In-source builds are not allowed.
10 | CMake would overwrite the makefiles distributed with bela.
11 | Please create a directory and run cmake from there, passing the path
12 | to this source directory as the last argument.
13 | This process created the file `CMakeCache.txt' and the directory `CMakeFiles'.
14 | Please delete them.")
15 | endif()
16 |
17 | option(ENABLE_BELA_TEST "Enable test" OFF)
18 | option(BELA_ENABLE_LTO "bela enable LTO" OFF)
19 | option(BELA_ENABLE_ASSEMBLY_FILES "bela enable assembly files" OFF)
20 |
21 | message(STATUS "CMAKE_ASM_COMPILER_ID ${CMAKE_ASM_COMPILER_ID}")
22 |
23 | if(NOT (DEFINED CMAKE_CXX_STANDARD))
24 | set(CMAKE_CXX_STANDARD 20)
25 | endif()
26 |
27 | if(CMAKE_CXX_STANDARD LESS 20 OR CMAKE_CXX_STANDARD STREQUAL "98")
28 | message(FATAL_ERROR "Bela requires C++20 or later")
29 | endif()
30 |
31 | set(CMAKE_CXX_STANDARD_REQUIRED YES)
32 |
33 | if("^${CMAKE_SOURCE_DIR}$" STREQUAL "^${PROJECT_SOURCE_DIR}$")
34 | set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
35 | set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
36 | if(MSVC)
37 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -utf-8 -W3 -DUNICODE=1 -D_UNICODE=1 -wd26812")
38 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -utf-8 -W3 -permissive- -Zc:__cplusplus -DUNICODE=1 -D_UNICODE=1 -wd26812")
39 | endif(MSVC)
40 | endif()
41 |
42 | include(CheckSymbolExists)
43 |
44 | if(MSVC)
45 | check_symbol_exists(_M_X64 "" BELA_ARCHITECTURE_64BIT)
46 | check_symbol_exists(_M_IX86 "" BELA_ARCHITECTURE_32BIT)
47 | check_symbol_exists(_M_ARM64 "" BELA_ARCHITECTURE_ARM64)
48 | else()
49 | check_symbol_exists(__x86_64__ "" BELA_ARCHITECTURE_64BIT)
50 | check_symbol_exists(__aarch64__ "" BELA_ARCHITECTURE_ARM64)
51 | endif()
52 |
53 | include_directories(include)
54 |
55 | add_subdirectory(src/bela)
56 | add_subdirectory(src/belawin)
57 | add_subdirectory(src/belashl)
58 | add_subdirectory(src/belatime)
59 | add_subdirectory(src/belaund)
60 | add_subdirectory(src/belahash)
61 | add_subdirectory(src/hazel)
62 | if(ENABLE_BELA_TEST)
63 | add_subdirectory(test)
64 | endif()
65 |
--------------------------------------------------------------------------------
/vendor/bela/CMakeSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "configurations": [
3 | {
4 | "name": "x64-Debug (默认值)",
5 | "generator": "Ninja",
6 | "configurationType": "Debug",
7 | "inheritEnvironments": [ "msvc_x64_x64" ],
8 | "buildRoot": "${projectDir}\\out\\build\\${name}",
9 | "installRoot": "${projectDir}\\out\\install\\${name}",
10 | "cmakeCommandArgs": "-DENABLE_BELA_TEST=ON",
11 | "buildCommandArgs": "",
12 | "ctestCommandArgs": "",
13 | "variables": []
14 | }
15 | ]
16 | }
--------------------------------------------------------------------------------
/vendor/bela/build.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 |
3 | pwsh -NoProfile -NoLogo -ExecutionPolicy unrestricted -File "%~dp0build.ps1" %*
--------------------------------------------------------------------------------
/vendor/bela/clang-tidy.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 |
3 | where pwsh.exe >nul 2>nul
4 | if %ERRORLEVEL% NEQ 0 (
5 | echo It is recommended to install PowerShell 7^+ for a better experience.
6 | powershell -NoProfile -NoLogo -ExecutionPolicy unrestricted -File "%~dp0clang-tidy.ps1" %*
7 | ) else (
8 | pwsh -NoProfile -NoLogo -ExecutionPolicy unrestricted -File "%~dp0clang-tidy.ps1" %*
9 | )
--------------------------------------------------------------------------------
/vendor/bela/compile_flags.txt:
--------------------------------------------------------------------------------
1 | -Wall
2 | -Wextra
3 | -pedantic
4 | -std=c++17
5 | -Iinclude
--------------------------------------------------------------------------------
/vendor/bela/docs/ReadMe.md:
--------------------------------------------------------------------------------
1 | # Bela docs
2 |
3 | Bela documents.
4 |
--------------------------------------------------------------------------------
/vendor/bela/docs/en-US/path.md:
--------------------------------------------------------------------------------
1 | # Path function
2 |
--------------------------------------------------------------------------------
/vendor/bela/docs/zh-CN/ReadMe.md:
--------------------------------------------------------------------------------
1 | # Bela 中文文档索引
2 |
3 | 1. StringCat 字符串函数:[StringCat](./strcat.md)
4 | 2. Path 路径函数:[path.md](./path.md)
5 | 3. StrFormat: [StrFormat](./strformat.md)
6 |
--------------------------------------------------------------------------------
/vendor/bela/docs/zh-CN/path.md:
--------------------------------------------------------------------------------
1 | # Windows Path Utility
2 |
3 | ## PathCat 函数
4 |
5 | `PathCat`,`JoinPath` 函数借鉴了 `StringCat` 函数,将路径组件连接起来。例子如下:
6 |
7 | ```c++
8 | auto p = bela::PathCat(L"\\\\?\\C:\\Windows/System32", L"drivers/etc", L"hosts");
9 | bela::FPrintF(stderr, L"PathCat: %s\n", p);
10 | auto p2 = bela::PathCat(L"C:\\Windows/System32", L"drivers/../..");
11 | bela::FPrintF(stderr, L"PathCat: %s\n", p2);
12 | auto p3 = bela::PathCat(L"Windows/System32", L"drivers/./././.\\.\\etc");
13 | bela::FPrintF(stderr, L"PathCat: %s\n", p3);
14 | auto p4 = bela::PathCat(L".", L"test/pathcat/./pathcat_test.exe");
15 | bela::FPrintF(stderr, L"PathCat: %s\n", p4);
16 | auto p5 = bela::PathCat(L"C:\\Windows\\System32\\drivers\\..\\.\\IME");
17 | bela::FPrintF(stderr, L"PathCat: %s\n", p5);
18 | ```
19 | `PathCat` 的思路是获得 root 后,将其他路径按路径分隔符拆分成数组然后合成,`JoinPath` 与 `PathCat` 不一致的地方在于,`JoinPath` 将会把路径参数中的第一个解析为绝对路径,然后再参与计算。
20 |
21 | `PathCat`,`JoinPath` 并不会判断路径是否存在,因此需要注意。
22 |
23 | 路径解析错误是很多软件的漏洞根源,合理的规范化路径非常有必要,而 `PathCat` 在规范化路径时,使用 C++17/C++20(Span) 的特性,减少内存分配,简化了规范化流程。
24 |
25 |
26 | ## PathExists 函数
27 |
28 | `PathExists` 函数判断路径是否存在,当使用默认参数时,只会判断路径是否存在,如果需要判断路径的其他属性,可以使用如下方式:
29 |
30 | ```c++
31 | if(!bela::PathExists(L"C:\\Windows",FileAttribute::Dir)){
32 | bela::FPrintF(stderr,L"C:\\Windows not dir or not exists\n");
33 | }
34 | ```
35 |
36 | ## LookupRealPath 函数
37 |
38 | `LookupRealPath` 用于解析 Windows 符号链接和卷挂载点。
39 |
40 | ## LookupAppExecLinkTarget 函数
41 |
42 | `LookupAppExecLinkTarget` 用于解析 Windows AppExecLink 目标,在 Windows 10 系统中,`AppExecLink` 是一种 Store App 的命令行入口,通常位于 `C:\Users\$Username\AppData\Local\Microsoft\WindowsApps`,这种文件本质上是一种重解析点,因此解析时需要按照重解析点的方法去解析。
43 |
--------------------------------------------------------------------------------
/vendor/bela/docs/zh-CN/strcat.md:
--------------------------------------------------------------------------------
1 | # StringCat 和 StrAppend 函数
2 |
--------------------------------------------------------------------------------
/vendor/bela/docs/zh-CN/strformat.md:
--------------------------------------------------------------------------------
1 | # StrFormat
2 |
3 | Bela 目前提供了一个类型安全简单的 `StrFormat`, `StrFormat` 基于 C++ 变参模板,使用 `union` 记录参数类型,在解析时按照输入的占位符将其他类型转换为字符串连接在一起,从而实现格式化功能。
4 |
5 | 支持的类型和响应的占位符如下表所示:
6 |
7 | |类型|占位符|备注|
8 | |---|---|---|
9 | |char|`%c`|ASCII 字符,会被提升为 wchar_t|
10 | |unsigned char|`%c`|ASCII 字符,会被提升为 wchar_t|
11 | |wchar_t|`%c`|UTF-16 字符|
12 | |char16_t|`%c`|UTF-16 字符|
13 | |char32_t|`%c`|UTF-32 Unicode 字符,会被转为 UTF-16 字符,这意味着可以使用 Unicode 码点以 %c 的方式输出 emoji。|
14 | |short|`%d`|16位整型|
15 | |unsigned short|`%d`|16位无符号整型|
16 | |int|`%d`|32位整型|
17 | |unsigned int|`%d`|32位无符号整型|
18 | |long|`%d`|32位整型|
19 | |unsigned long|`%d`|32位无符号整型|
20 | |long long|`%d`|64位整型|
21 | |unsigned long long|`%d`|64位无符号整型|
22 | |float|`%f`|会被提升为 `double`|
23 | |double|`%f`|64位浮点|
24 | |const char *|`%s`|UTF-8 字符串,会被转换成 UTF-16 字符串|
25 | |char *|`%s`|UTF-8 字符串,会被转换成 UTF-16 字符串|
26 | |std::string|`%s`|UTF-8 字符串,会被转换成 UTF-16 字符串|
27 | |std::string_view|`%s`|UTF-8 字符串,会被转换成 UTF-16 字符串|
28 | |const wchar_t *|`%s`|UTF-16 字符串|
29 | |wchar_t *|`%s`|UTF-16 字符串|
30 | |std::wstring|`%s`|UTF-16 字符串|
31 | |std::wstring_view|`%s`|UTF-16 字符串|
32 | |const char16_t *|`%s`|UTF-16 字符串|
33 | |char16_t *|`%s`|UTF-16 字符串|
34 | |std::u16string|`%s`|UTF-16 字符串|
35 | |std::u16string_view|`%s`|UTF-16 字符串|
36 | |void *|`%p`|指针类型,会格式化成 `0xffff00000` 这样的字符串|
37 |
38 | 如果不格式化 UTF-8 字符串,且拥有固定大小内存缓冲区,可以使用 `StrFormat` 的如下重载,此重载可以轻松的移植到 POSIX 系统并支持异步信号安全:
39 |
40 | ```c++
41 | template
42 | ssize_t StrFormat(wchar_t *buf, size_t N, const wchar_t *fmt, const Args& ... args)
43 | ```
44 |
45 | ## 示例
46 |
47 | ```cpp
48 | ///
49 | #include
50 | #include
51 |
52 | int wmain(int argc, wchar_t **argv) {
53 | auto ux = "\xf0\x9f\x98\x81 UTF-8 text \xE3\x8D\xA4"; // force encode UTF-8
54 | wchar_t wx[] = L"Engine \xD83D\xDEE0 中国";
55 | bela::FPrintF(
56 | stderr,
57 | L"Argc: %d Arg0: \x1b[32m%s\x1b[0m W: %s UTF-8: %s __cplusplus: %d\n", argc, argv[0], wx, ux, __cplusplus);
58 | char32_t em = 0x1F603;//😃
59 | auto s = bela::StringCat(L"Look emoji -->", em, L" U: ",
60 | static_cast(em));
61 | bela::FPrintF(stderr, L"emoji test %c %s\n", em, s);
62 | return 0;
63 | }
64 |
65 | ```
66 |
67 | 请注意,如果上述 emoji 要正常显示,应当使用 `Windows Terminal` 或者是 `Mintty`。
68 |
--------------------------------------------------------------------------------
/vendor/bela/external/charconv/VERSION:
--------------------------------------------------------------------------------
1 | https://github.com/microsoft/stl/tree/5404ba9c25f26f25a0ac50e6c4defce7833a8da6
2 |
--------------------------------------------------------------------------------
/vendor/bela/external/charconv/xcharconv.h:
--------------------------------------------------------------------------------
1 | // xcharconv.h internal header
2 |
3 | // Copyright (c) Microsoft Corporation.
4 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5 |
6 | #pragma once
7 | #ifndef _XCHARCONV_H
8 | #define _XCHARCONV_H
9 | #include
10 | #if _STL_COMPILER_PREPROCESSOR
11 |
12 | #include
13 | #include
14 | #include
15 |
16 | #if !_HAS_CXX17
17 | #error The contents of are only available with C++17. (Also, you should not include this internal header.)
18 | #endif // !_HAS_CXX17
19 |
20 | #pragma pack(push, _CRT_PACKING)
21 | #pragma warning(push, _STL_WARNING_LEVEL)
22 | #pragma warning(disable : _STL_DISABLED_WARNINGS)
23 | _STL_DISABLE_CLANG_WARNINGS
24 | #pragma push_macro("new")
25 | #undef new
26 |
27 | _STD_BEGIN
28 | _EXPORT_STD enum class chars_format {
29 | scientific = 0b001,
30 | fixed = 0b010,
31 | hex = 0b100,
32 | general = fixed | scientific,
33 | };
34 |
35 | _BITMASK_OPS(_EXPORT_STD, chars_format)
36 |
37 | _EXPORT_STD struct to_chars_result {
38 | char* ptr;
39 | errc ec;
40 | #if _HAS_CXX20
41 | _NODISCARD_FRIEND bool operator==(const to_chars_result&, const to_chars_result&) = default;
42 | #endif // _HAS_CXX20
43 | };
44 |
45 | _STD_END
46 |
47 | #pragma pop_macro("new")
48 | _STL_RESTORE_CLANG_WARNINGS
49 | #pragma warning(pop)
50 | #pragma pack(pop)
51 |
52 | #endif // _STL_COMPILER_PREPROCESSOR
53 | #endif // _XCHARCONV_H
54 |
--------------------------------------------------------------------------------
/vendor/bela/external/ntimage.h.txt:
--------------------------------------------------------------------------------
1 | 10.0.22000.1
--------------------------------------------------------------------------------
/vendor/bela/include/bela/__charconv/tables.hpp:
--------------------------------------------------------------------------------
1 | // -*- C++ -*-
2 | //===----------------------------------------------------------------------===//
3 | //
4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 | // See https://llvm.org/LICENSE.txt for license information.
6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 | //
8 | //===----------------------------------------------------------------------===//
9 |
10 | #ifndef _BELA___CHARCONV_TABLES
11 | #define _BELA___CHARCONV_TABLES
12 |
13 | namespace bela::__itoa {
14 |
15 | constexpr wchar_t __digits_base_10[200] = {
16 | // clang-format off
17 | '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9',
18 | '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '1', '8', '1', '9',
19 | '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5', '2', '6', '2', '7', '2', '8', '2', '9',
20 | '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '3', '8', '3', '9',
21 | '4', '0', '4', '1', '4', '2', '4', '3', '4', '4', '4', '5', '4', '6', '4', '7', '4', '8', '4', '9',
22 | '5', '0', '5', '1', '5', '2', '5', '3', '5', '4', '5', '5', '5', '6', '5', '7', '5', '8', '5', '9',
23 | '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', '6', '7', '6', '8', '6', '9',
24 | '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7', '7', '8', '7', '9',
25 | '8', '0', '8', '1', '8', '2', '8', '3', '8', '4', '8', '5', '8', '6', '8', '7', '8', '8', '8', '9',
26 | '9', '0', '9', '1', '9', '2', '9', '3', '9', '4', '9', '5', '9', '6', '9', '7', '9', '8', '9', '9'};
27 | // clang-format on
28 |
29 | } // namespace bela::__itoa
30 |
31 | #endif // _LIBCPP___CHARCONV_TABLES
--------------------------------------------------------------------------------
/vendor/bela/include/bela/__phmap/VERSION:
--------------------------------------------------------------------------------
1 | https://github.com/greg7mdp/parallel-hashmap.git
2 | 77cab8192a879e5d27188f97e8f2080dd7e36ca8
3 |
--------------------------------------------------------------------------------
/vendor/bela/include/bela/btree.hpp:
--------------------------------------------------------------------------------
1 | ///
2 | #ifndef BELA_BTREE_HPP
3 | #define BELA_BTREE_HPP
4 | #include "__phmap/btree.h"
5 |
6 | namespace bela {
7 | using phmap::btree_map;
8 | using phmap::btree_multimap;
9 | using phmap::btree_set;
10 | } // namespace bela
11 |
12 | #endif
13 |
--------------------------------------------------------------------------------
/vendor/bela/include/bela/buffer.hpp:
--------------------------------------------------------------------------------
1 | ///
2 | #ifndef BELA_BUFFER_HPP
3 | #define BELA_BUFFER_HPP
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include "bytes_view.hpp"
9 |
10 | namespace bela {
11 |
12 | class Buffer {
13 | private:
14 | std::allocator alloc_;
15 | void MoveFrom(Buffer &&other) {
16 | Free(); // Free self
17 | data_ = other.data_;
18 | alloc_ = std::move(other.alloc_);
19 | other.data_ = nullptr;
20 | capacity_ = other.capacity_;
21 | other.capacity_ = 0;
22 | size_ = other.size_;
23 | other.size_ = 0;
24 | }
25 | void Free() {
26 | if (data_ != nullptr) {
27 | alloc_.deallocate(data_, capacity_);
28 | data_ = nullptr;
29 | capacity_ = 0;
30 | size_ = 0;
31 | }
32 | }
33 |
34 | public:
35 | Buffer() = default;
36 | Buffer(size_t maxsize) { grow(maxsize); }
37 | Buffer(Buffer &&other) { MoveFrom(std::move(other)); }
38 | Buffer &operator=(Buffer &&other) {
39 | MoveFrom(std::move(other));
40 | return *this;
41 | }
42 | Buffer(const Buffer &) = delete;
43 | Buffer &operator=(const Buffer &) = delete;
44 | ~Buffer() { Free(); }
45 | [[nodiscard]] size_t size() const { return size_; }
46 | [[nodiscard]] size_t &size() { return size_; }
47 | [[nodiscard]] size_t capacity() const { return capacity_; }
48 | void grow(size_t n) {
49 | if (n <= capacity_) {
50 | return;
51 | }
52 | auto b = alloc_.allocate(n);
53 | if (size_ != 0) {
54 | memcpy(b, data_, size_);
55 | }
56 | if (data_ != nullptr) {
57 | alloc_.deallocate(data_, capacity_);
58 | }
59 | data_ = b;
60 | capacity_ = n;
61 | }
62 | [[nodiscard]] const uint8_t *data() const { return data_; }
63 | [[nodiscard]] uint8_t operator[](const size_t _Off) const noexcept { return *(data_ + _Off); }
64 | [[nodiscard]] uint8_t *data() { return data_; }
65 | std::span make_const_span() const { return std::span{data_, size_}; }
66 | std::span make_span(size_t spanlen = std::string_view::npos) const {
67 | return std::span{data_, (std::min)(capacity_, spanlen)};
68 | }
69 | auto as_bytes_view() const { return bytes_view(data_, size_); }
70 |
71 | private:
72 | uint8_t *data_{nullptr};
73 | size_t size_{0};
74 | size_t capacity_{0};
75 | };
76 |
77 | } // namespace bela
78 |
79 | #endif
--------------------------------------------------------------------------------
/vendor/bela/include/bela/bufio.hpp:
--------------------------------------------------------------------------------
1 | //
2 | #ifndef BELA_BUFIO_HPP
3 | #define BELA_BUFIO_HPP
4 | #include
5 | #include "base.hpp"
6 | #include "types.hpp"
7 |
8 | namespace bela::bufio {
9 | constexpr ssize_t default_buffer_size = 4096;
10 | // Fixed capacity size bufio.Reader implementation
11 | template class Reader {
12 | public:
13 | Reader(HANDLE r) : fd(r) {}
14 | Reader(const Reader &) = delete;
15 | Reader &operator=(const Reader &) = delete;
16 | ssize_t Buffered() const { return w - r; }
17 | ssize_t Read(void *buffer, ssize_t len, bela::error_code &ec) {
18 | if (buffer == nullptr || len == 0) {
19 | ec = bela::make_error_code(L"short read");
20 | return -1;
21 | }
22 | if (r == w) {
23 | if (static_cast(len) > sizeof(data)) {
24 | // Large read, empty buffer.
25 | // Read directly into p to avoid copy.
26 | ssize_t rlen = 0;
27 | if (!fsread(buffer, len, rlen, ec)) {
28 | return -1;
29 | }
30 | return rlen;
31 | }
32 | w = 0;
33 | r = 0;
34 | if (!fsread(data, sizeof(data), w, ec)) {
35 | return -1;
36 | }
37 | if (w == 0) {
38 | ec = bela::make_error_code(L"unexpected EOF");
39 | return -1;
40 | }
41 | }
42 |
43 | auto n = (std::min)(w - r, len);
44 | memcpy(buffer, data + r, n);
45 | r += n;
46 | return n;
47 | }
48 | ssize_t ReadFull(void *buffer, ssize_t len, bela::error_code &ec) {
49 | auto p = reinterpret_cast(buffer);
50 | ssize_t n = 0;
51 | for (; n < len;) {
52 | auto nn = Read(p + n, len - n, ec);
53 | if (nn == -1) {
54 | return -1;
55 | }
56 | n += nn;
57 | }
58 | if (n < len) {
59 | ec = bela::make_error_code(L"unexpected EOF");
60 | return -1;
61 | }
62 | return n;
63 | }
64 |
65 | constexpr int size() const { return Size; }
66 |
67 | private:
68 | HANDLE fd{INVALID_HANDLE_VALUE};
69 | uint8_t data[Size] = {0};
70 | ssize_t w{0};
71 | ssize_t r{0};
72 | bool fsread(void *b, ssize_t len, ssize_t &rlen, bela::error_code &ec) {
73 | DWORD dwSize = {0};
74 | if (::ReadFile(fd, b, static_cast(len), &dwSize, nullptr) != TRUE) {
75 | ec = bela::make_system_error_code(L"ReadFile: ");
76 | return false;
77 | }
78 | rlen = static_cast(len);
79 | return true;
80 | }
81 | };
82 | } // namespace bela::bufio
83 |
84 | #endif
--------------------------------------------------------------------------------
/vendor/bela/include/bela/escaping.hpp:
--------------------------------------------------------------------------------
1 | // ---------------------------------------------------------------------------
2 | // Copyright © 2023, Bela contributors
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // https://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 | //
16 | // Includes work from abseil-cpp (https://github.com/abseil/abseil-cpp)
17 | // with modifications.
18 | //
19 | // Copyright 2019 The Abseil Authors.
20 | //
21 | // Licensed under the Apache License, Version 2.0 (the "License");
22 | // you may not use this file except in compliance with the License.
23 | // You may obtain a copy of the License at
24 | //
25 | // https://www.apache.org/licenses/LICENSE-2.0
26 | //
27 | // Unless required by applicable law or agreed to in writing, software
28 | // distributed under the License is distributed on an "AS IS" BASIS,
29 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30 | // See the License for the specific language governing permissions and
31 | // limitations under the License.
32 | // ---------------------------------------------------------------------------
33 | #ifndef BELA_ESCAPING_HPP
34 | #define BELA_ESCAPING_HPP
35 | #include
36 | #include
37 | #include
38 | #include
39 |
40 | namespace bela {
41 | bool CUnescape(std::wstring_view source, std::wstring *dest, std::wstring *error);
42 |
43 | // Overload of `CUnescape()` with no error reporting.
44 | inline bool CUnescape(std::wstring_view source, std::wstring *dest) { return CUnescape(source, dest, nullptr); }
45 | std::wstring CEscape(std::wstring_view src);
46 | } // namespace bela
47 |
48 | #endif
49 |
--------------------------------------------------------------------------------
/vendor/bela/include/bela/fnmatch.hpp:
--------------------------------------------------------------------------------
1 | //
2 | #ifndef BELA_FNMATCH_HPP
3 | #define BELA_FNMATCH_HPP
4 | #include
5 |
6 | namespace bela {
7 | namespace fnmatch {
8 | [[maybe_unused]] constexpr int NoEscape = 0x1;
9 | [[maybe_unused]] constexpr int PathName = 0x2;
10 | [[maybe_unused]] constexpr int Period = 0x4;
11 | [[maybe_unused]] constexpr int LeadingDir = 0x8;
12 | [[maybe_unused]] constexpr int CaseFold = 0x10;
13 | [[maybe_unused]] constexpr int IgnoreCase = 0x10;
14 | [[maybe_unused]] constexpr int FileName = PathName;
15 | } // namespace fnmatch
16 | // POSIX fnmatch impl see http://man7.org/linux/man-pages/man3/fnmatch.3.html
17 |
18 | bool FnMatch(std::u16string_view pattern, std::u16string_view text, int flags = 0);
19 | inline bool FnMatch(std::wstring_view pattern, std::wstring_view text, int flags = 0) {
20 | return FnMatch({reinterpret_cast(pattern.data()), pattern.size()},
21 | {reinterpret_cast(text.data()), text.size()}, flags);
22 | }
23 | bool FnMatch(std::u8string_view pattern, std::u8string_view text, int flags = 0);
24 | inline bool FnMatch(std::string_view pattern, std::string_view text, int flags = 0) {
25 | return FnMatch({reinterpret_cast(pattern.data()), pattern.size()},
26 | {reinterpret_cast(text.data()), text.size()}, flags);
27 | }
28 |
29 | } // namespace bela
30 |
31 | #endif
--------------------------------------------------------------------------------
/vendor/bela/include/bela/fs.hpp:
--------------------------------------------------------------------------------
1 | ///
2 | #ifndef BELA_FS_HPP
3 | #define BELA_FS_HPP
4 | #include "base.hpp"
5 | #include "str_cat.hpp"
6 | #include
7 |
8 | namespace bela::fs {
9 | constexpr bool DirSkipFaster(const wchar_t *dir) {
10 | return (dir[0] == L'.' && (dir[1] == L'\0' || (dir[1] == L'.' && dir[2] == L'\0')));
11 | }
12 |
13 | class Finder {
14 | public:
15 | Finder() noexcept = default;
16 | Finder(const Finder &) = delete;
17 | Finder &operator=(const Finder &) = delete;
18 | ~Finder() noexcept {
19 | if (hFind != INVALID_HANDLE_VALUE) {
20 | FindClose(hFind);
21 | }
22 | }
23 | const WIN32_FIND_DATAW &FD() const { return wfd; }
24 | bool Ignore() const { return DirSkipFaster(wfd.cFileName); }
25 | bool IsDir() const { return (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; }
26 | bool IsReparsePoint() const { return (wfd.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0; }
27 | int64_t Size() const {
28 | LARGE_INTEGER li{{
29 | .LowPart = wfd.nFileSizeLow,
30 | .HighPart = static_cast(wfd.nFileSizeHigh),
31 | }};
32 | return li.QuadPart;
33 | }
34 | std::wstring_view Name() const { return std::wstring_view(wfd.cFileName); }
35 | bool Next() { return FindNextFileW(hFind, &wfd) == TRUE; }
36 | bool First(std::wstring_view file, bela::error_code &ec) {
37 | if (hFind != INVALID_HANDLE_VALUE) {
38 | ec = bela::make_error_code(L"Find handle not invalid");
39 | return false;
40 | }
41 | hFind = FindFirstFileW(file.data(), &wfd);
42 | if (hFind == INVALID_HANDLE_VALUE) {
43 | ec = bela::make_system_error_code();
44 | return false;
45 | }
46 | return true;
47 | }
48 | bool First(std::wstring_view dir, std::wstring_view suffix, bela::error_code &ec) {
49 | auto d = bela::StringCat(dir, L"\\", suffix);
50 | return First(d, ec);
51 | }
52 |
53 | private:
54 | HANDLE hFind{INVALID_HANDLE_VALUE};
55 | WIN32_FIND_DATAW wfd;
56 | };
57 | // Remove remove file force
58 | bool ForceDeleteFile(HANDLE FileHandle, bela::error_code &ec);
59 | bool ForceDeleteFile(std::wstring_view path, bela::error_code &ec);
60 | bool ForceDeleteFolders(std::wstring_view path, bela::error_code &ec);
61 | } // namespace bela::fs
62 |
63 | #endif
--------------------------------------------------------------------------------
/vendor/bela/include/bela/phmap.hpp:
--------------------------------------------------------------------------------
1 | //////////////////////
2 | #ifndef BELA_PHMAP_HPP
3 | #define BELA_PHMAP_HPP
4 | #include "__phmap/phmap.h"
5 |
6 | namespace bela {
7 | using phmap::flat_hash_map;
8 | using phmap::flat_hash_set;
9 | using phmap::node_hash_map;
10 | using phmap::node_hash_set;
11 | using phmap::parallel_flat_hash_map;
12 | using phmap::parallel_flat_hash_set;
13 | using phmap::parallel_node_hash_map;
14 | using phmap::parallel_node_hash_set;
15 | } // namespace bela
16 |
17 | #endif
--------------------------------------------------------------------------------
/vendor/bela/include/bela/picker.hpp:
--------------------------------------------------------------------------------
1 | #ifndef BELA_PICKER_HPP
2 | #define BELA_PICKER_HPP
3 | #include "base.hpp"
4 | #include
5 | #include
6 |
7 | namespace bela {
8 | // Messagebox type
9 | enum class mbs_t {
10 | INFO, //
11 | WARN,
12 | FATAL,
13 | ABOUT
14 | };
15 |
16 | bool BelaMessageBox(HWND hWnd, LPCWSTR pszWindowTitle, LPCWSTR pszContent, LPCWSTR pszExpandedInfo,
17 | mbs_t mt = mbs_t::ABOUT);
18 | using filter_t = COMDLG_FILTERSPEC;
19 | std::optional FilePicker(HWND hWnd, const wchar_t *title, const filter_t *fts, size_t flen);
20 | template
21 | inline std::optional FilePicker(HWND hWnd, const wchar_t *title, const filter_t (&fts)[N]) {
22 | return FilePicker(hWnd, title, fts, N);
23 | }
24 | std::optional FolderPicker(HWND hWnd, const wchar_t *title);
25 | } // namespace bela
26 |
27 | #endif
--------------------------------------------------------------------------------
/vendor/bela/include/bela/process.hpp:
--------------------------------------------------------------------------------
1 | // bela::process type
2 | #ifndef BELA_PROCESS_HPP
3 | #define BELA_PROCESS_HPP
4 | #include "base.hpp"
5 | #include "escapeargv.hpp"
6 | #include "simulator.hpp"
7 |
8 | namespace bela::process {
9 | constexpr const wchar_t *string_nullable(std::wstring_view str) { return str.empty() ? nullptr : str.data(); }
10 | constexpr wchar_t *string_nullable(std::wstring &str) { return str.empty() ? nullptr : str.data(); }
11 |
12 | enum CaptureMode : DWORD {
13 | CAPTURE_OUT = 0, // default
14 | CAPTURE_ERR = 0x1,
15 | CAPTURE_USEIN = 0x2,
16 | CAPTURE_USEERR = 0x4,
17 | };
18 | using bela::env::Simulator;
19 | class Process {
20 | public:
21 | Process(const Simulator *simulator_ = nullptr) : simulator(simulator_) {}
22 | Process(const Process &) = delete;
23 | Process &operator=(const Process &) = delete;
24 | Process &Chdir(std::wstring_view dir) {
25 | cwd = dir;
26 | return *this;
27 | }
28 | const bela::error_code &ErrorCode() const { return ec; }
29 | const DWORD ExitCode() const { return exitcode; }
30 | std::string_view Out() const { return out; } // when call Capture
31 | template int Execute(std::wstring_view cmd, const Args &...args) {
32 | bela::EscapeArgv ea(cmd, args...);
33 | exitcode = ExecuteInternal(cmd, ea.data());
34 | return exitcode;
35 | }
36 | template int Capture(std::wstring_view cmd, const Args &...args) {
37 | bela::EscapeArgv ea(cmd, args...);
38 | exitcode = CaptureInternal(cmd, ea.data(), CAPTURE_OUT);
39 | return exitcode;
40 | }
41 | template int CaptureWithMode(DWORD flags, std::wstring_view cmd, const Args &...args) {
42 | bela::EscapeArgv ea(cmd, args...);
43 | exitcode = CaptureInternal(cmd, ea.data(), flags);
44 | return exitcode;
45 | }
46 |
47 | private:
48 | int ExecuteInternal(std::wstring_view file, wchar_t *cmdline);
49 | int CaptureInternal(std::wstring_view file, wchar_t *cmdline, DWORD flags);
50 | const Simulator *simulator{nullptr};
51 | std::wstring cwd;
52 | std::string out;
53 | bela::error_code ec;
54 | DWORD pid{0};
55 | DWORD exitcode{0};
56 | };
57 | } // namespace bela::process
58 |
59 | #endif
--------------------------------------------------------------------------------
/vendor/bela/include/bela/terminal.hpp:
--------------------------------------------------------------------------------
1 | //
2 | #ifndef BELA_TERMINAL_HPP
3 | #define BELA_TERMINAL_HPP
4 | #include "base.hpp"
5 | #include "fmt.hpp"
6 |
7 | namespace bela {
8 | namespace terminal {
9 | // Is same terminal maybe console or Cygwin pty
10 | bool IsSameTerminal(HANDLE fd);
11 | bool IsSameTerminal(FILE *fd);
12 |
13 | // Is console terminal
14 | bool IsTerminal(HANDLE fd);
15 | bool IsTerminal(FILE *fd);
16 |
17 | // Is cygwin terminal
18 | bool IsCygwinTerminal(HANDLE fd);
19 | bool IsCygwinTerminal(FILE *fd);
20 |
21 | struct terminal_size {
22 | uint32_t columns{0};
23 | uint32_t rows{0};
24 | };
25 | bool TerminalSize(HANDLE fd, terminal_size &sz);
26 | bool TerminalSize(FILE *fd, terminal_size &sz);
27 | bela::ssize_t WriteTerminal(HANDLE fd, std::wstring_view data);
28 | bela::ssize_t WriteSameFile(HANDLE fd, std::wstring_view data);
29 | bela::ssize_t WriteSameFile(HANDLE fd, std::string_view data);
30 | // Warning, currently bela :: terminal :: WriteAuto does not support redirect
31 | // operations like freopen, please do not use this
32 | bela::ssize_t WriteAuto(FILE *fd, std::wstring_view data);
33 | // UTF-8 version cache write
34 | bela::ssize_t WriteAuto(FILE *fd, std::string_view data);
35 | // If you need to call freopen, you should use the following:
36 | bela::ssize_t WriteDirect(FILE *fd, std::wstring_view data);
37 | // UTF-8 version direct write
38 | bela::ssize_t WriteDirect(FILE *fd, std::string_view data);
39 | } // namespace terminal
40 | template ssize_t FPrintF(FILE *out, const wchar_t *fmt, const Args &...args) {
41 | const format_internal::FormatArg arg_array[] = {args...};
42 | auto str = format_internal::StrFormatInternal(fmt, arg_array, sizeof...(args));
43 | return bela::terminal::WriteAuto(out, str);
44 | }
45 |
46 | inline ssize_t FPrintF(FILE *out, const wchar_t *fmt) { return bela::terminal::WriteAuto(out, fmt); }
47 |
48 | template ssize_t FPrintDirectF(FILE *out, const wchar_t *fmt, const Args &...args) {
49 | const format_internal::FormatArg arg_array[] = {args...};
50 | auto str = format_internal::StrFormatInternal(fmt, arg_array, sizeof...(args));
51 | return bela::terminal::WriteDirect(out, str);
52 | }
53 |
54 | inline ssize_t FPrintDirectF(FILE *out, const wchar_t *fmt) { return bela::terminal::WriteDirect(out, fmt); }
55 |
56 | } // namespace bela
57 | #endif
--------------------------------------------------------------------------------
/vendor/bela/include/bela/und.hpp:
--------------------------------------------------------------------------------
1 | ///
2 | #ifndef BELA_UND_HPP
3 | #define BELA_UND_HPP
4 | #include
5 |
6 | namespace llvm {
7 | std::string demangle(std::string_view MangledName);
8 | }
9 | namespace bela {
10 | using llvm::demangle;
11 | }
12 |
13 | #endif
--------------------------------------------------------------------------------
/vendor/bela/include/hazel/details/ELFRelocs/AMDGPU.def:
--------------------------------------------------------------------------------
1 | #ifndef ELF_RELOC
2 | #error "ELF_RELOC must be defined"
3 | #endif
4 |
5 | ELF_RELOC(R_AMDGPU_NONE, 0)
6 | ELF_RELOC(R_AMDGPU_ABS32_LO, 1)
7 | ELF_RELOC(R_AMDGPU_ABS32_HI, 2)
8 | ELF_RELOC(R_AMDGPU_ABS64, 3)
9 | ELF_RELOC(R_AMDGPU_REL32, 4)
10 | ELF_RELOC(R_AMDGPU_REL64, 5)
11 | ELF_RELOC(R_AMDGPU_ABS32, 6)
12 | ELF_RELOC(R_AMDGPU_GOTPCREL, 7)
13 | ELF_RELOC(R_AMDGPU_GOTPCREL32_LO, 8)
14 | ELF_RELOC(R_AMDGPU_GOTPCREL32_HI, 9)
15 | ELF_RELOC(R_AMDGPU_REL32_LO, 10)
16 | ELF_RELOC(R_AMDGPU_REL32_HI, 11)
17 | ELF_RELOC(R_AMDGPU_RELATIVE64, 13)
18 | ELF_RELOC(R_AMDGPU_REL16, 14)
19 |
--------------------------------------------------------------------------------
/vendor/bela/include/hazel/details/ELFRelocs/AVR.def:
--------------------------------------------------------------------------------
1 |
2 | #ifndef ELF_RELOC
3 | #error "ELF_RELOC must be defined"
4 | #endif
5 |
6 | ELF_RELOC(R_AVR_NONE, 0)
7 | ELF_RELOC(R_AVR_32, 1)
8 | ELF_RELOC(R_AVR_7_PCREL, 2)
9 | ELF_RELOC(R_AVR_13_PCREL, 3)
10 | ELF_RELOC(R_AVR_16, 4)
11 | ELF_RELOC(R_AVR_16_PM, 5)
12 | ELF_RELOC(R_AVR_LO8_LDI, 6)
13 | ELF_RELOC(R_AVR_HI8_LDI, 7)
14 | ELF_RELOC(R_AVR_HH8_LDI, 8)
15 | ELF_RELOC(R_AVR_LO8_LDI_NEG, 9)
16 | ELF_RELOC(R_AVR_HI8_LDI_NEG, 10)
17 | ELF_RELOC(R_AVR_HH8_LDI_NEG, 11)
18 | ELF_RELOC(R_AVR_LO8_LDI_PM, 12)
19 | ELF_RELOC(R_AVR_HI8_LDI_PM, 13)
20 | ELF_RELOC(R_AVR_HH8_LDI_PM, 14)
21 | ELF_RELOC(R_AVR_LO8_LDI_PM_NEG, 15)
22 | ELF_RELOC(R_AVR_HI8_LDI_PM_NEG, 16)
23 | ELF_RELOC(R_AVR_HH8_LDI_PM_NEG, 17)
24 | ELF_RELOC(R_AVR_CALL, 18)
25 | ELF_RELOC(R_AVR_LDI, 19)
26 | ELF_RELOC(R_AVR_6, 20)
27 | ELF_RELOC(R_AVR_6_ADIW, 21)
28 | ELF_RELOC(R_AVR_MS8_LDI, 22)
29 | ELF_RELOC(R_AVR_MS8_LDI_NEG, 23)
30 | ELF_RELOC(R_AVR_LO8_LDI_GS, 24)
31 | ELF_RELOC(R_AVR_HI8_LDI_GS, 25)
32 | ELF_RELOC(R_AVR_8, 26)
33 | ELF_RELOC(R_AVR_8_LO8, 27)
34 | ELF_RELOC(R_AVR_8_HI8, 28)
35 | ELF_RELOC(R_AVR_8_HLO8, 29)
36 | ELF_RELOC(R_AVR_DIFF8, 30)
37 | ELF_RELOC(R_AVR_DIFF16, 31)
38 | ELF_RELOC(R_AVR_DIFF32, 32)
39 | ELF_RELOC(R_AVR_LDS_STS_16, 33)
40 | ELF_RELOC(R_AVR_PORT6, 34)
41 | ELF_RELOC(R_AVR_PORT5, 35)
42 |
--------------------------------------------------------------------------------
/vendor/bela/include/hazel/details/ELFRelocs/BPF.def:
--------------------------------------------------------------------------------
1 | #ifndef ELF_RELOC
2 | #error "ELF_RELOC must be defined"
3 | #endif
4 |
5 | // No relocation
6 | ELF_RELOC(R_BPF_NONE, 0)
7 | ELF_RELOC(R_BPF_64_64, 1)
8 | ELF_RELOC(R_BPF_64_ABS64, 2)
9 | ELF_RELOC(R_BPF_64_ABS32, 3)
10 | ELF_RELOC(R_BPF_64_NODYLD32, 4)
11 | ELF_RELOC(R_BPF_64_32, 10)
12 |
--------------------------------------------------------------------------------
/vendor/bela/include/hazel/details/ELFRelocs/Lanai.def:
--------------------------------------------------------------------------------
1 |
2 | #ifndef ELF_RELOC
3 | #error "ELF_RELOC must be defined"
4 | #endif
5 |
6 | // No relocation
7 | ELF_RELOC(R_LANAI_NONE, 0)
8 | // 21-bit symbol relocation
9 | ELF_RELOC(R_LANAI_21, 1)
10 | // 21-bit symbol relocation with last two bits masked to 0
11 | ELF_RELOC(R_LANAI_21_F, 2)
12 | // 25-bit branch targets
13 | ELF_RELOC(R_LANAI_25, 3)
14 | // General 32-bit relocation
15 | ELF_RELOC(R_LANAI_32, 4)
16 | // Upper 16-bits of a symbolic relocation
17 | ELF_RELOC(R_LANAI_HI16, 5)
18 | // Lower 16-bits of a symbolic relocation
19 | ELF_RELOC(R_LANAI_LO16, 6)
20 |
--------------------------------------------------------------------------------
/vendor/bela/include/hazel/details/ELFRelocs/M68k.def:
--------------------------------------------------------------------------------
1 | #ifndef ELF_RELOC
2 | #error "ELF_RELOC must be defined"
3 | #endif
4 |
5 | ELF_RELOC(R_68K_NONE, 0) /* No reloc */
6 | ELF_RELOC(R_68K_32, 1) /* Direct 32 bit */
7 | ELF_RELOC(R_68K_16, 2) /* Direct 16 bit */
8 | ELF_RELOC(R_68K_8, 3) /* Direct 8 bit */
9 | ELF_RELOC(R_68K_PC32, 4) /* PC relative 32 bit */
10 | ELF_RELOC(R_68K_PC16, 5) /* PC relative 16 bit */
11 | ELF_RELOC(R_68K_PC8, 6) /* PC relative 8 bit */
12 | ELF_RELOC(R_68K_GOTPCREL32, 7) /* 32 bit PC relative GOT entry */
13 | ELF_RELOC(R_68K_GOTPCREL16, 8) /* 16 bit PC relative GOT entry */
14 | ELF_RELOC(R_68K_GOTPCREL8, 9) /* 8 bit PC relative GOT entry */
15 | ELF_RELOC(R_68K_GOTOFF32, 10) /* 32 bit GOT offset */
16 | ELF_RELOC(R_68K_GOTOFF16, 11) /* 16 bit GOT offset */
17 | ELF_RELOC(R_68K_GOTOFF8, 12) /* 8 bit GOT offset */
18 | ELF_RELOC(R_68K_PLT32, 13) /* 32 bit PC relative PLT address */
19 | ELF_RELOC(R_68K_PLT16, 14) /* 16 bit PC relative PLT address */
20 | ELF_RELOC(R_68K_PLT8, 15) /* 8 bit PC relative PLT address */
21 | ELF_RELOC(R_68K_PLTOFF32, 16) /* 32 bit PLT offset */
22 | ELF_RELOC(R_68K_PLTOFF16, 17) /* 16 bit PLT offset */
23 | ELF_RELOC(R_68K_PLTOFF8, 18) /* 8 bit PLT offset */
24 | ELF_RELOC(R_68K_COPY, 19) /* Copy symbol at runtime */
25 | ELF_RELOC(R_68K_GLOB_DAT, 20) /* Create GOT entry */
26 | ELF_RELOC(R_68K_JMP_SLOT, 21) /* Create PLT entry */
27 | ELF_RELOC(R_68K_RELATIVE, 22) /* Adjust by program base */
28 | /* These are GNU extensions to enable C++ vtable garbage collection. */
29 | ELF_RELOC(R_68K_GNU_VTINHERIT, 23)
30 | ELF_RELOC(R_68K_GNU_VTENTRY, 24)
31 | /* TLS static relocations. */
32 | ELF_RELOC(R_68K_TLS_GD32, 25)
33 | ELF_RELOC(R_68K_TLS_GD16, 26)
34 | ELF_RELOC(R_68K_TLS_GD8, 27)
35 | ELF_RELOC(R_68K_TLS_LDM32, 28)
36 | ELF_RELOC(R_68K_TLS_LDM16, 29)
37 | ELF_RELOC(R_68K_TLS_LDM8, 30)
38 | ELF_RELOC(R_68K_TLS_LDO32, 31)
39 | ELF_RELOC(R_68K_TLS_LDO16, 32)
40 | ELF_RELOC(R_68K_TLS_LDO8, 33)
41 | ELF_RELOC(R_68K_TLS_IE32, 34)
42 | ELF_RELOC(R_68K_TLS_IE16, 35)
43 | ELF_RELOC(R_68K_TLS_IE8, 36)
44 | ELF_RELOC(R_68K_TLS_LE32, 37)
45 | ELF_RELOC(R_68K_TLS_LE16, 38)
46 | ELF_RELOC(R_68K_TLS_LE8, 39)
47 | ELF_RELOC(R_68K_TLS_DTPMOD32, 40)
48 | ELF_RELOC(R_68K_TLS_DTPREL32, 41)
49 | ELF_RELOC(R_68K_TLS_TPREL32, 42)
50 |
--------------------------------------------------------------------------------
/vendor/bela/include/hazel/details/ELFRelocs/MSP430.def:
--------------------------------------------------------------------------------
1 |
2 | #ifndef ELF_RELOC
3 | #error "ELF_RELOC must be defined"
4 | #endif
5 |
6 | ELF_RELOC(R_MSP430_NONE, 0)
7 | ELF_RELOC(R_MSP430_32, 1)
8 | ELF_RELOC(R_MSP430_10_PCREL, 2)
9 | ELF_RELOC(R_MSP430_16, 3)
10 | ELF_RELOC(R_MSP430_16_PCREL, 4)
11 | ELF_RELOC(R_MSP430_16_BYTE, 5)
12 | ELF_RELOC(R_MSP430_16_PCREL_BYTE, 6)
13 | ELF_RELOC(R_MSP430_2X_PCREL, 7)
14 | ELF_RELOC(R_MSP430_RL_PCREL, 8)
15 | ELF_RELOC(R_MSP430_8, 9)
16 | ELF_RELOC(R_MSP430_SYM_DIFF, 10)
17 |
--------------------------------------------------------------------------------
/vendor/bela/include/hazel/details/ELFRelocs/RISCV.def:
--------------------------------------------------------------------------------
1 |
2 | #ifndef ELF_RELOC
3 | #error "ELF_RELOC must be defined"
4 | #endif
5 |
6 | ELF_RELOC(R_RISCV_NONE, 0)
7 | ELF_RELOC(R_RISCV_32, 1)
8 | ELF_RELOC(R_RISCV_64, 2)
9 | ELF_RELOC(R_RISCV_RELATIVE, 3)
10 | ELF_RELOC(R_RISCV_COPY, 4)
11 | ELF_RELOC(R_RISCV_JUMP_SLOT, 5)
12 | ELF_RELOC(R_RISCV_TLS_DTPMOD32, 6)
13 | ELF_RELOC(R_RISCV_TLS_DTPMOD64, 7)
14 | ELF_RELOC(R_RISCV_TLS_DTPREL32, 8)
15 | ELF_RELOC(R_RISCV_TLS_DTPREL64, 9)
16 | ELF_RELOC(R_RISCV_TLS_TPREL32, 10)
17 | ELF_RELOC(R_RISCV_TLS_TPREL64, 11)
18 | ELF_RELOC(R_RISCV_BRANCH, 16)
19 | ELF_RELOC(R_RISCV_JAL, 17)
20 | ELF_RELOC(R_RISCV_CALL, 18)
21 | ELF_RELOC(R_RISCV_CALL_PLT, 19)
22 | ELF_RELOC(R_RISCV_GOT_HI20, 20)
23 | ELF_RELOC(R_RISCV_TLS_GOT_HI20, 21)
24 | ELF_RELOC(R_RISCV_TLS_GD_HI20, 22)
25 | ELF_RELOC(R_RISCV_PCREL_HI20, 23)
26 | ELF_RELOC(R_RISCV_PCREL_LO12_I, 24)
27 | ELF_RELOC(R_RISCV_PCREL_LO12_S, 25)
28 | ELF_RELOC(R_RISCV_HI20, 26)
29 | ELF_RELOC(R_RISCV_LO12_I, 27)
30 | ELF_RELOC(R_RISCV_LO12_S, 28)
31 | ELF_RELOC(R_RISCV_TPREL_HI20, 29)
32 | ELF_RELOC(R_RISCV_TPREL_LO12_I, 30)
33 | ELF_RELOC(R_RISCV_TPREL_LO12_S, 31)
34 | ELF_RELOC(R_RISCV_TPREL_ADD, 32)
35 | ELF_RELOC(R_RISCV_ADD8, 33)
36 | ELF_RELOC(R_RISCV_ADD16, 34)
37 | ELF_RELOC(R_RISCV_ADD32, 35)
38 | ELF_RELOC(R_RISCV_ADD64, 36)
39 | ELF_RELOC(R_RISCV_SUB8, 37)
40 | ELF_RELOC(R_RISCV_SUB16, 38)
41 | ELF_RELOC(R_RISCV_SUB32, 39)
42 | ELF_RELOC(R_RISCV_SUB64, 40)
43 | ELF_RELOC(R_RISCV_GNU_VTINHERIT, 41)
44 | ELF_RELOC(R_RISCV_GNU_VTENTRY, 42)
45 | ELF_RELOC(R_RISCV_ALIGN, 43)
46 | ELF_RELOC(R_RISCV_RVC_BRANCH, 44)
47 | ELF_RELOC(R_RISCV_RVC_JUMP, 45)
48 | ELF_RELOC(R_RISCV_RVC_LUI, 46)
49 | ELF_RELOC(R_RISCV_RELAX, 51)
50 | ELF_RELOC(R_RISCV_SUB6, 52)
51 | ELF_RELOC(R_RISCV_SET6, 53)
52 | ELF_RELOC(R_RISCV_SET8, 54)
53 | ELF_RELOC(R_RISCV_SET16, 55)
54 | ELF_RELOC(R_RISCV_SET32, 56)
55 | ELF_RELOC(R_RISCV_32_PCREL, 57)
56 | ELF_RELOC(R_RISCV_IRELATIVE, 58)
57 |
--------------------------------------------------------------------------------
/vendor/bela/include/hazel/details/ELFRelocs/SystemZ.def:
--------------------------------------------------------------------------------
1 |
2 | #ifndef ELF_RELOC
3 | #error "ELF_RELOC must be defined"
4 | #endif
5 |
6 | ELF_RELOC(R_390_NONE, 0)
7 | ELF_RELOC(R_390_8, 1)
8 | ELF_RELOC(R_390_12, 2)
9 | ELF_RELOC(R_390_16, 3)
10 | ELF_RELOC(R_390_32, 4)
11 | ELF_RELOC(R_390_PC32, 5)
12 | ELF_RELOC(R_390_GOT12, 6)
13 | ELF_RELOC(R_390_GOT32, 7)
14 | ELF_RELOC(R_390_PLT32, 8)
15 | ELF_RELOC(R_390_COPY, 9)
16 | ELF_RELOC(R_390_GLOB_DAT, 10)
17 | ELF_RELOC(R_390_JMP_SLOT, 11)
18 | ELF_RELOC(R_390_RELATIVE, 12)
19 | ELF_RELOC(R_390_GOTOFF, 13)
20 | ELF_RELOC(R_390_GOTPC, 14)
21 | ELF_RELOC(R_390_GOT16, 15)
22 | ELF_RELOC(R_390_PC16, 16)
23 | ELF_RELOC(R_390_PC16DBL, 17)
24 | ELF_RELOC(R_390_PLT16DBL, 18)
25 | ELF_RELOC(R_390_PC32DBL, 19)
26 | ELF_RELOC(R_390_PLT32DBL, 20)
27 | ELF_RELOC(R_390_GOTPCDBL, 21)
28 | ELF_RELOC(R_390_64, 22)
29 | ELF_RELOC(R_390_PC64, 23)
30 | ELF_RELOC(R_390_GOT64, 24)
31 | ELF_RELOC(R_390_PLT64, 25)
32 | ELF_RELOC(R_390_GOTENT, 26)
33 | ELF_RELOC(R_390_GOTOFF16, 27)
34 | ELF_RELOC(R_390_GOTOFF64, 28)
35 | ELF_RELOC(R_390_GOTPLT12, 29)
36 | ELF_RELOC(R_390_GOTPLT16, 30)
37 | ELF_RELOC(R_390_GOTPLT32, 31)
38 | ELF_RELOC(R_390_GOTPLT64, 32)
39 | ELF_RELOC(R_390_GOTPLTENT, 33)
40 | ELF_RELOC(R_390_PLTOFF16, 34)
41 | ELF_RELOC(R_390_PLTOFF32, 35)
42 | ELF_RELOC(R_390_PLTOFF64, 36)
43 | ELF_RELOC(R_390_TLS_LOAD, 37)
44 | ELF_RELOC(R_390_TLS_GDCALL, 38)
45 | ELF_RELOC(R_390_TLS_LDCALL, 39)
46 | ELF_RELOC(R_390_TLS_GD32, 40)
47 | ELF_RELOC(R_390_TLS_GD64, 41)
48 | ELF_RELOC(R_390_TLS_GOTIE12, 42)
49 | ELF_RELOC(R_390_TLS_GOTIE32, 43)
50 | ELF_RELOC(R_390_TLS_GOTIE64, 44)
51 | ELF_RELOC(R_390_TLS_LDM32, 45)
52 | ELF_RELOC(R_390_TLS_LDM64, 46)
53 | ELF_RELOC(R_390_TLS_IE32, 47)
54 | ELF_RELOC(R_390_TLS_IE64, 48)
55 | ELF_RELOC(R_390_TLS_IEENT, 49)
56 | ELF_RELOC(R_390_TLS_LE32, 50)
57 | ELF_RELOC(R_390_TLS_LE64, 51)
58 | ELF_RELOC(R_390_TLS_LDO32, 52)
59 | ELF_RELOC(R_390_TLS_LDO64, 53)
60 | ELF_RELOC(R_390_TLS_DTPMOD, 54)
61 | ELF_RELOC(R_390_TLS_DTPOFF, 55)
62 | ELF_RELOC(R_390_TLS_TPOFF, 56)
63 | ELF_RELOC(R_390_20, 57)
64 | ELF_RELOC(R_390_GOT20, 58)
65 | ELF_RELOC(R_390_GOTPLT20, 59)
66 | ELF_RELOC(R_390_TLS_GOTIE20, 60)
67 | ELF_RELOC(R_390_IRELATIVE, 61)
68 | ELF_RELOC(R_390_PC12DBL, 62)
69 | ELF_RELOC(R_390_PLT12DBL, 63)
70 | ELF_RELOC(R_390_PC24DBL, 64)
71 | ELF_RELOC(R_390_PLT24DBL, 65)
72 |
--------------------------------------------------------------------------------
/vendor/bela/include/hazel/details/ELFRelocs/VE.def:
--------------------------------------------------------------------------------
1 |
2 | #ifndef ELF_RELOC
3 | #error "ELF_RELOC must be defined"
4 | #endif
5 |
6 | // Relocation types defined in following documents.
7 | //
8 | // - System V Application Binary Interface - VE Architecture
9 | // Processor Supplement
10 | // - ELF Handling For Thread-Local Storage - VE Architecture
11 | // Processor Supplement
12 |
13 | ELF_RELOC(R_VE_NONE, 0)
14 | ELF_RELOC(R_VE_REFLONG, 1)
15 | ELF_RELOC(R_VE_REFQUAD, 2)
16 | ELF_RELOC(R_VE_SREL32, 3)
17 | ELF_RELOC(R_VE_HI32, 4)
18 | ELF_RELOC(R_VE_LO32, 5)
19 | ELF_RELOC(R_VE_PC_HI32, 6)
20 | ELF_RELOC(R_VE_PC_LO32, 7)
21 | ELF_RELOC(R_VE_GOT32, 8)
22 | ELF_RELOC(R_VE_GOT_HI32, 9)
23 | ELF_RELOC(R_VE_GOT_LO32, 10)
24 | ELF_RELOC(R_VE_GOTOFF32, 11)
25 | ELF_RELOC(R_VE_GOTOFF_HI32, 12)
26 | ELF_RELOC(R_VE_GOTOFF_LO32, 13)
27 | ELF_RELOC(R_VE_PLT32, 14)
28 | ELF_RELOC(R_VE_PLT_HI32, 15)
29 | ELF_RELOC(R_VE_PLT_LO32, 16)
30 | ELF_RELOC(R_VE_RELATIVE, 17)
31 | ELF_RELOC(R_VE_GLOB_DAT, 18)
32 | ELF_RELOC(R_VE_JUMP_SLOT, 19)
33 | ELF_RELOC(R_VE_COPY, 20)
34 | ELF_RELOC(R_VE_DTPMOD64, 22)
35 | ELF_RELOC(R_VE_DTPOFF64, 23)
36 | // ELF_RELOC(R_VE_TPOFF64, 24)
37 | ELF_RELOC(R_VE_TLS_GD_HI32, 25)
38 | ELF_RELOC(R_VE_TLS_GD_LO32, 26)
39 | // ELF_RELOC(R_VE_TLS_LD_HI32, 27)
40 | // ELF_RELOC(R_VE_TLS_LD_LO32, 28)
41 | // ELF_RELOC(R_VE_DTPOFF32, 29)
42 | // ELF_RELOC(R_VE_TLS_IE_HI32, 30)
43 | // ELF_RELOC(R_VE_TLS_IE_LO32, 31)
44 | ELF_RELOC(R_VE_TPOFF_HI32, 32)
45 | ELF_RELOC(R_VE_TPOFF_LO32, 33)
46 | // ELF_RELOC(R_VE_TPOFF32, 34)
47 | ELF_RELOC(R_VE_CALL_HI32, 35)
48 | ELF_RELOC(R_VE_CALL_LO32, 36)
49 |
--------------------------------------------------------------------------------
/vendor/bela/include/hazel/details/ELFRelocs/i386.def:
--------------------------------------------------------------------------------
1 |
2 | #ifndef ELF_RELOC
3 | #error "ELF_RELOC must be defined"
4 | #endif
5 |
6 | // TODO: this is just a subset
7 | ELF_RELOC(R_386_NONE, 0)
8 | ELF_RELOC(R_386_32, 1)
9 | ELF_RELOC(R_386_PC32, 2)
10 | ELF_RELOC(R_386_GOT32, 3)
11 | ELF_RELOC(R_386_PLT32, 4)
12 | ELF_RELOC(R_386_COPY, 5)
13 | ELF_RELOC(R_386_GLOB_DAT, 6)
14 | ELF_RELOC(R_386_JUMP_SLOT, 7)
15 | ELF_RELOC(R_386_RELATIVE, 8)
16 | ELF_RELOC(R_386_GOTOFF, 9)
17 | ELF_RELOC(R_386_GOTPC, 10)
18 | ELF_RELOC(R_386_32PLT, 11)
19 | ELF_RELOC(R_386_TLS_TPOFF, 14)
20 | ELF_RELOC(R_386_TLS_IE, 15)
21 | ELF_RELOC(R_386_TLS_GOTIE, 16)
22 | ELF_RELOC(R_386_TLS_LE, 17)
23 | ELF_RELOC(R_386_TLS_GD, 18)
24 | ELF_RELOC(R_386_TLS_LDM, 19)
25 | ELF_RELOC(R_386_16, 20)
26 | ELF_RELOC(R_386_PC16, 21)
27 | ELF_RELOC(R_386_8, 22)
28 | ELF_RELOC(R_386_PC8, 23)
29 | ELF_RELOC(R_386_TLS_GD_32, 24)
30 | ELF_RELOC(R_386_TLS_GD_PUSH, 25)
31 | ELF_RELOC(R_386_TLS_GD_CALL, 26)
32 | ELF_RELOC(R_386_TLS_GD_POP, 27)
33 | ELF_RELOC(R_386_TLS_LDM_32, 28)
34 | ELF_RELOC(R_386_TLS_LDM_PUSH, 29)
35 | ELF_RELOC(R_386_TLS_LDM_CALL, 30)
36 | ELF_RELOC(R_386_TLS_LDM_POP, 31)
37 | ELF_RELOC(R_386_TLS_LDO_32, 32)
38 | ELF_RELOC(R_386_TLS_IE_32, 33)
39 | ELF_RELOC(R_386_TLS_LE_32, 34)
40 | ELF_RELOC(R_386_TLS_DTPMOD32, 35)
41 | ELF_RELOC(R_386_TLS_DTPOFF32, 36)
42 | ELF_RELOC(R_386_TLS_TPOFF32, 37)
43 | ELF_RELOC(R_386_TLS_GOTDESC, 39)
44 | ELF_RELOC(R_386_TLS_DESC_CALL, 40)
45 | ELF_RELOC(R_386_TLS_DESC, 41)
46 | ELF_RELOC(R_386_IRELATIVE, 42)
47 | ELF_RELOC(R_386_GOT32X, 43)
48 |
--------------------------------------------------------------------------------
/vendor/bela/include/hazel/details/ELFRelocs/x86_64.def:
--------------------------------------------------------------------------------
1 |
2 | #ifndef ELF_RELOC
3 | #error "ELF_RELOC must be defined"
4 | #endif
5 |
6 | ELF_RELOC(R_X86_64_NONE, 0)
7 | ELF_RELOC(R_X86_64_64, 1)
8 | ELF_RELOC(R_X86_64_PC32, 2)
9 | ELF_RELOC(R_X86_64_GOT32, 3)
10 | ELF_RELOC(R_X86_64_PLT32, 4)
11 | ELF_RELOC(R_X86_64_COPY, 5)
12 | ELF_RELOC(R_X86_64_GLOB_DAT, 6)
13 | ELF_RELOC(R_X86_64_JUMP_SLOT, 7)
14 | ELF_RELOC(R_X86_64_RELATIVE, 8)
15 | ELF_RELOC(R_X86_64_GOTPCREL, 9)
16 | ELF_RELOC(R_X86_64_32, 10)
17 | ELF_RELOC(R_X86_64_32S, 11)
18 | ELF_RELOC(R_X86_64_16, 12)
19 | ELF_RELOC(R_X86_64_PC16, 13)
20 | ELF_RELOC(R_X86_64_8, 14)
21 | ELF_RELOC(R_X86_64_PC8, 15)
22 | ELF_RELOC(R_X86_64_DTPMOD64, 16)
23 | ELF_RELOC(R_X86_64_DTPOFF64, 17)
24 | ELF_RELOC(R_X86_64_TPOFF64, 18)
25 | ELF_RELOC(R_X86_64_TLSGD, 19)
26 | ELF_RELOC(R_X86_64_TLSLD, 20)
27 | ELF_RELOC(R_X86_64_DTPOFF32, 21)
28 | ELF_RELOC(R_X86_64_GOTTPOFF, 22)
29 | ELF_RELOC(R_X86_64_TPOFF32, 23)
30 | ELF_RELOC(R_X86_64_PC64, 24)
31 | ELF_RELOC(R_X86_64_GOTOFF64, 25)
32 | ELF_RELOC(R_X86_64_GOTPC32, 26)
33 | ELF_RELOC(R_X86_64_GOT64, 27)
34 | ELF_RELOC(R_X86_64_GOTPCREL64, 28)
35 | ELF_RELOC(R_X86_64_GOTPC64, 29)
36 | ELF_RELOC(R_X86_64_GOTPLT64, 30)
37 | ELF_RELOC(R_X86_64_PLTOFF64, 31)
38 | ELF_RELOC(R_X86_64_SIZE32, 32)
39 | ELF_RELOC(R_X86_64_SIZE64, 33)
40 | ELF_RELOC(R_X86_64_GOTPC32_TLSDESC, 34)
41 | ELF_RELOC(R_X86_64_TLSDESC_CALL, 35)
42 | ELF_RELOC(R_X86_64_TLSDESC, 36)
43 | ELF_RELOC(R_X86_64_IRELATIVE, 37)
44 | ELF_RELOC(R_X86_64_GOTPCRELX, 41)
45 | ELF_RELOC(R_X86_64_REX_GOTPCRELX, 42)
46 |
--------------------------------------------------------------------------------
/vendor/bela/include/hazel/details/version.lock:
--------------------------------------------------------------------------------
1 | https://github.com/llvm/llvm-project/tree/0c8bfbb37484957557f2a16a7ae56ca987bafd4d/llvm/include/llvm/BinaryFormat
--------------------------------------------------------------------------------
/vendor/bela/include/hazel/fs.hpp:
--------------------------------------------------------------------------------
1 | ///
2 | #ifndef HAZEL_FS_HPP
3 | #define HAZEL_FS_HPP
4 | #include
5 | #include
6 |
7 | namespace hazel::fs {
8 | typedef enum reparse_point_e : unsigned long {
9 | MOUNT_POINT = 0xA0000003,
10 | HSM = 0xC0000004,
11 | DRIVE_EXTENDER = 0x80000005,
12 | HSM2 = 0x80000006,
13 | SIS = 0x80000007,
14 | WIM = 0x80000008,
15 | CSV = 0x80000009,
16 | DFS = 0x8000000A,
17 | FILTER_MANAGER = 0x8000000B,
18 | SYMLINK = 0xA000000C,
19 | IIS_CACHE = 0xA0000010,
20 | DFSR = 0x80000012,
21 | DEDUP = 0x80000013,
22 | APPXSTRM = 0xC0000014,
23 | NFS = 0x80000014,
24 | FILE_PLACEHOLDER = 0x80000015,
25 | DFM = 0x80000016,
26 | WOF = 0x80000017,
27 | WCI = 0x80000018,
28 | WCI_1 = 0x90001018,
29 | GLOBAL_REPARSE = 0xA0000019,
30 | CLOUD = 0x9000001A,
31 | CLOUD_1 = 0x9000101A,
32 | CLOUD_2 = 0x9000201A,
33 | CLOUD_3 = 0x9000301A,
34 | CLOUD_4 = 0x9000401A,
35 | CLOUD_5 = 0x9000501A,
36 | CLOUD_6 = 0x9000601A,
37 | CLOUD_7 = 0x9000701A,
38 | CLOUD_8 = 0x9000801A,
39 | CLOUD_9 = 0x9000901A,
40 | CLOUD_A = 0x9000A01A,
41 | CLOUD_B = 0x9000B01A,
42 | CLOUD_C = 0x9000C01A,
43 | CLOUD_D = 0x9000D01A,
44 | CLOUD_E = 0x9000E01A,
45 | CLOUD_F = 0x9000F01A,
46 | CLOUD_MASK = 0x0000F000,
47 | APPEXECLINK = 0x8000001B,
48 | PROJFS = 0x9000001C,
49 | LX_SYMLINK = 0xA000001D,
50 | STORAGE_SYNC = 0x8000001E,
51 | WCI_TOMBSTONE = 0xA000001F,
52 | UNHANDLED = 0x80000020,
53 | ONEDRIVE = 0x80000021,
54 | PROJFS_TOMBSTONE = 0xA0000022,
55 | AF_UNIX = 0x80000023,
56 | LX_FIFO = 0x80000024,
57 | LX_CHR = 0x80000025,
58 | LX_BLK = 0x80000026,
59 | WCI_LINK = 0xA0000027,
60 | WCI_LINK_1 = 0xA0001027,
61 | } reparse_point_t;
62 |
63 | struct FileReparsePoint {
64 | bela::flat_hash_map attributes;
65 | reparse_point_t type;
66 | };
67 |
68 | bool LookupReparsePoint(std::wstring_view file, FileReparsePoint &frp, bela::error_code &ec);
69 |
70 | } // namespace hazel::fs
71 |
72 | #endif
--------------------------------------------------------------------------------
/vendor/bela/res/1903.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | PerMonitorV2
15 | true
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/vendor/bela/res/longPathAware.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | true
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/vendor/bela/res/utf8activeCodePage.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | UTF-8
7 |
8 |
9 |
10 |
11 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/vendor/bela/res/win10.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 | Bela
4 |
5 |
6 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | true/PM
27 | PerMonitorV2, PerMonitor
28 | true
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/vendor/bela/src/bela/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # bela base libaray
2 |
3 | add_library(
4 | bela STATIC
5 | errno.cc
6 | ascii.cc
7 | city.cc
8 | codecvt.cc
9 | escaping.cc
10 | int128.cc
11 | match.cc
12 | numbers.cc
13 | str_split.cc
14 | str_split_narrow.cc
15 | str_replace.cc
16 | str_cat.cc
17 | subsitute.cc
18 | terminal.cc
19 | __charconv/charconv_float.cc
20 | __fnmatch/fnmatch.cc
21 | __format/fmt.cc)
22 |
23 | if(BELA_ENABLE_LTO)
24 | set_property(TARGET bela PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
25 | endif()
26 |
--------------------------------------------------------------------------------
/vendor/bela/src/bela/__fnmatch/fnmatch_internal.hpp:
--------------------------------------------------------------------------------
1 | ///
2 | #ifndef BELA_FNMATCH_INTERNAL_HPP
3 | #define BELA_FNMATCH_INTERNAL_HPP
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | namespace bela::fnmatch_internal {
10 | constexpr int END = 0;
11 | constexpr int UNMATCHABLE = -2;
12 | constexpr int BRACKET = -3;
13 | constexpr int QUESTION = -4;
14 | constexpr int STAR = -5;
15 |
16 | constexpr bool ascii_isalpha_u16_template(wchar_t c) { return true; }
17 |
18 | constexpr bool ascii_isalpha_u8_template(char8_t c) { return true; }
19 |
20 | constexpr bool same_character_matched(char16_t wc, std::u16string_view sv) {
21 | constexpr struct {
22 | std::u16string_view sv;
23 | decltype(ascii_isalpha_u16_template) *fn;
24 | } matchers[] = {
25 | {u"alnum", bela::ascii_isalnum}, {u"alpha", bela::ascii_isalpha}, {u"blank", bela::ascii_isblank},
26 | {u"cntrl", bela::ascii_iscntrl}, {u"digit", bela::ascii_isdigit}, {u"graph", bela::ascii_isgraph},
27 | {u"lower", bela::ascii_islower}, {u"print", bela::ascii_isprint}, {u"punct", bela::ascii_ispunct},
28 | {u"space", bela::ascii_isspace}, {u"upper", bela::ascii_isupper}, {u"xdigit", bela::ascii_isxdigit},
29 | };
30 | for (const auto &m : matchers) {
31 | if (m.sv == sv) {
32 | return m.fn(wc);
33 | }
34 | }
35 | return false;
36 | }
37 |
38 | constexpr bool same_character_matched(char8_t wc, std::u8string_view sv) {
39 | constexpr struct {
40 | std::u8string_view sv;
41 | decltype(ascii_isalpha_u8_template) *fn;
42 | } matchers[] = {
43 | {u8"alnum", bela::ascii_isalnum}, {u8"alpha", bela::ascii_isalpha}, {u8"blank", bela::ascii_isblank},
44 | {u8"cntrl", bela::ascii_iscntrl}, {u8"digit", bela::ascii_isdigit}, {u8"graph", bela::ascii_isgraph},
45 | {u8"lower", bela::ascii_islower}, {u8"print", bela::ascii_isprint}, {u8"punct", bela::ascii_ispunct},
46 | {u8"space", bela::ascii_isspace}, {u8"upper", bela::ascii_isupper}, {u8"xdigit", bela::ascii_isxdigit},
47 | };
48 | for (const auto &m : matchers) {
49 | if (m.sv == sv) {
50 | return m.fn(wc);
51 | }
52 | }
53 | return false;
54 | }
55 |
56 | } // namespace bela::fnmatch_internal
57 |
58 | #endif
--------------------------------------------------------------------------------
/vendor/bela/src/bela/codecvt.cc:
--------------------------------------------------------------------------------
1 | //////////
2 | // see:
3 | // https://github.com/llvm-mirror/llvm/blob/master/lib/Support/ConvertUTF.cpp
4 | //
5 | #include
6 | #include
7 | #include
8 |
9 | namespace bela {
10 |
11 | bool bisearch(char32_t rune, const bela::unicode::interval *table, size_t max) {
12 | size_t min = 0;
13 | size_t mid;
14 | if (rune < table[0].first || rune > table[max].last) {
15 | return false;
16 | }
17 | while (max >= min) {
18 | mid = (min + max) / 2;
19 | if (rune > table[mid].last) {
20 | min = mid + 1;
21 | continue;
22 | }
23 | if (rune < table[mid].first) {
24 | max = mid - 1;
25 | continue;
26 | }
27 | return true;
28 | }
29 | return false;
30 | }
31 |
32 | size_t rune_width(char32_t rune) {
33 | // control characters we return 0;
34 | if (rune == 0 || rune > 0x10FFFF || rune < 32 || (rune >= 0x7F && rune < 0xa0)) {
35 | return 0;
36 | }
37 | if (bisearch(rune, bela::unicode::zero_width, std::size(bela::unicode::zero_width) - 1)) {
38 | return 0;
39 | }
40 | if (bisearch(rune, bela::unicode::double_width, std::size(bela::unicode::double_width) - 1)) {
41 | return 2;
42 | }
43 | return 1;
44 | }
45 |
46 | } // namespace bela
47 |
--------------------------------------------------------------------------------
/vendor/bela/src/belahash/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # bela::hash https://docs.microsoft.com/en-us/cpp/intrinsics/arm64-intrinsics
2 | # https://static.docs.arm.com/ihi0073/c/IHI0073C_arm_neon_intrinsics_ref.pdf
3 |
4 | set(BELA_BLAKE3_SOURCES blake3/blake3.c blake3/blake3_dispatch.c blake3/blake3_portable.c)
5 |
6 | if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
7 | set(BELA_ENABLE_ASSEMBLY_FILES ON)
8 | endif()
9 |
10 |
11 | # FIXME CMAKE CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT
12 | if(BELA_ARCHITECTURE_64BIT)
13 | if(BELA_ENABLE_ASSEMBLY_FILES)
14 | if(MSVC)
15 | enable_language(ASM_MASM)
16 | list(
17 | APPEND
18 | BELA_BLAKE3_SOURCES
19 | blake3/blake3_sse2_x86-64_windows_msvc.asm
20 | blake3/blake3_sse41_x86-64_windows_msvc.asm
21 | blake3/blake3_avx2_x86-64_windows_msvc.asm
22 | blake3/blake3_avx512_x86-64_windows_msvc.asm)
23 | elseif(WIN32 OR CYGWIN)
24 | list(
25 | APPEND
26 | BELA_BLAKE3_SOURCES
27 | blake3/blake3_sse2_x86-64_windows_gnu.S
28 | blake3/blake3_sse41_x86-64_windows_gnu.S
29 | blake3/blake3_avx2_x86-64_windows_gnu.S
30 | blake3/blake3_avx512_x86-64_windows_gnu.S)
31 | else()
32 | list(
33 | APPEND
34 | BELA_BLAKE3_SOURCES
35 | blake3/blake3_sse2_x86-64_unix.S
36 | blake3/blake3_sse41_x86-64_unix.S
37 | blake3/blake3_avx2_x86-64_unix.S
38 | blake3/blake3_avx512_x86-64_unix.S)
39 | endif()
40 | else()
41 | list(
42 | APPEND
43 | BELA_BLAKE3_SOURCES
44 | blake3/blake3_sse2.c
45 | blake3/blake3_sse41.c
46 | blake3/blake3_avx2.c
47 | blake3/blake3_avx512.c)
48 | endif(BELA_ENABLE_ASSEMBLY_FILES)
49 | elseif(BELA_ARCHITECTURE_ARM64)
50 | list(APPEND BELA_BLAKE3_SOURCES blake3/blake3_neon.c)
51 | elseif(BELA_ARCHITECTURE_32BIT)
52 | list(
53 | APPEND
54 | BELA_BLAKE3_SOURCES
55 | blake3/blake3_sse2.c
56 | blake3/blake3_sse41.c
57 | blake3/blake3_avx2.c
58 | blake3/blake3_avx512.c)
59 | endif()
60 |
61 | add_library(
62 | belahash STATIC
63 | sha256.cc
64 | sha512.cc
65 | sha3.cc
66 | sm3.cc
67 | ${BELA_BLAKE3_SOURCES})
68 |
69 | target_link_libraries(belahash bela)
70 |
71 | if(BELA_ENABLE_LTO)
72 | set_property(TARGET belahash PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
73 | endif()
74 |
--------------------------------------------------------------------------------
/vendor/bela/src/belahash/ReadMe.md:
--------------------------------------------------------------------------------
1 | # Bela Hash Library
2 |
3 | This directory includes the implementation of the SHA256/SHA512/SHA3/BLAKE3 hash algorithm, in which the code of SHA256/SHA512/SHA3 based on librhash is adjusted to the C++17 paradigm, thanks to the rhash author for his efforts. Thanks also to BLAKE3 contributors.
--------------------------------------------------------------------------------
/vendor/bela/src/belahash/blake3.lock:
--------------------------------------------------------------------------------
1 | https://github.com/BLAKE3-team/BLAKE3
2 | 12823b87604cbb7bcd0e5cdc347a53f80b2a617c
3 |
--------------------------------------------------------------------------------
/vendor/bela/src/belahash/blake3/.gitignore:
--------------------------------------------------------------------------------
1 | blake3
2 | example
3 | *.o
4 |
--------------------------------------------------------------------------------
/vendor/bela/src/belahash/blake3/Makefile.testing:
--------------------------------------------------------------------------------
1 | # This Makefile is only for testing. C callers should follow the instructions
2 | # in ./README.md to incorporate these C files into their existing build.
3 |
4 | NAME=blake3
5 | CC=gcc
6 | CFLAGS=-O3 -Wall -Wextra -std=c11 -pedantic -fstack-protector-strong -D_FORTIFY_SOURCE=2 -fPIE -fvisibility=hidden
7 | LDFLAGS=-pie -Wl,-z,relro,-z,now
8 | TARGETS=
9 | ASM_TARGETS=
10 | EXTRAFLAGS=-Wa,--noexecstack
11 |
12 | ifdef BLAKE3_NO_SSE2
13 | EXTRAFLAGS += -DBLAKE3_NO_SSE2
14 | else
15 | TARGETS += blake3_sse2.o
16 | ASM_TARGETS += blake3_sse2_x86-64_unix.S
17 | endif
18 |
19 | ifdef BLAKE3_NO_SSE41
20 | EXTRAFLAGS += -DBLAKE3_NO_SSE41
21 | else
22 | TARGETS += blake3_sse41.o
23 | ASM_TARGETS += blake3_sse41_x86-64_unix.S
24 | endif
25 |
26 | ifdef BLAKE3_NO_AVX2
27 | EXTRAFLAGS += -DBLAKE3_NO_AVX2
28 | else
29 | TARGETS += blake3_avx2.o
30 | ASM_TARGETS += blake3_avx2_x86-64_unix.S
31 | endif
32 |
33 | ifdef BLAKE3_NO_AVX512
34 | EXTRAFLAGS += -DBLAKE3_NO_AVX512
35 | else
36 | TARGETS += blake3_avx512.o
37 | ASM_TARGETS += blake3_avx512_x86-64_unix.S
38 | endif
39 |
40 | ifdef BLAKE3_USE_NEON
41 | EXTRAFLAGS += -DBLAKE3_USE_NEON=1
42 | TARGETS += blake3_neon.o
43 | endif
44 |
45 | ifdef BLAKE3_NO_NEON
46 | EXTRAFLAGS += -DBLAKE3_USE_NEON=0
47 | endif
48 |
49 | all: blake3.c blake3_dispatch.c blake3_portable.c main.c $(TARGETS)
50 | $(CC) $(CFLAGS) $(EXTRAFLAGS) $^ -o $(NAME) $(LDFLAGS)
51 |
52 | blake3_sse2.o: blake3_sse2.c
53 | $(CC) $(CFLAGS) $(EXTRAFLAGS) -c $^ -o $@ -msse2
54 |
55 | blake3_sse41.o: blake3_sse41.c
56 | $(CC) $(CFLAGS) $(EXTRAFLAGS) -c $^ -o $@ -msse4.1
57 |
58 | blake3_avx2.o: blake3_avx2.c
59 | $(CC) $(CFLAGS) $(EXTRAFLAGS) -c $^ -o $@ -mavx2
60 |
61 | blake3_avx512.o: blake3_avx512.c
62 | $(CC) $(CFLAGS) $(EXTRAFLAGS) -c $^ -o $@ -mavx512f -mavx512vl
63 |
64 | blake3_neon.o: blake3_neon.c
65 | $(CC) $(CFLAGS) $(EXTRAFLAGS) -c $^ -o $@
66 |
67 | test: CFLAGS += -DBLAKE3_TESTING -fsanitize=address,undefined
68 | test: all
69 | ./test.py
70 |
71 | asm: blake3.c blake3_dispatch.c blake3_portable.c main.c $(ASM_TARGETS)
72 | $(CC) $(CFLAGS) $(EXTRAFLAGS) $^ -o $(NAME) $(LDFLAGS)
73 |
74 | test_asm: CFLAGS += -DBLAKE3_TESTING -fsanitize=address,undefined
75 | test_asm: asm
76 | ./test.py
77 |
78 | example: example.c blake3.c blake3_dispatch.c blake3_portable.c $(ASM_TARGETS)
79 | $(CC) $(CFLAGS) $(EXTRAFLAGS) $^ -o $@ $(LDFLAGS)
80 |
81 | clean:
82 | rm -f $(NAME) *.o
83 |
--------------------------------------------------------------------------------
/vendor/bela/src/belahash/blake3/blake3-config.cmake.in:
--------------------------------------------------------------------------------
1 | @PACKAGE_INIT@
2 |
3 | include("${CMAKE_CURRENT_LIST_DIR}/blake3-targets.cmake")
4 |
5 | check_required_components(blake3)
--------------------------------------------------------------------------------
/vendor/bela/src/belahash/blake3/example.c:
--------------------------------------------------------------------------------
1 | #include "blake3.h"
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | int main(void) {
9 | // Initialize the hasher.
10 | blake3_hasher hasher;
11 | blake3_hasher_init(&hasher);
12 |
13 | // Read input bytes from stdin.
14 | unsigned char buf[65536];
15 | while (1) {
16 | ssize_t n = read(STDIN_FILENO, buf, sizeof(buf));
17 | if (n > 0) {
18 | blake3_hasher_update(&hasher, buf, n);
19 | } else if (n == 0) {
20 | break; // end of file
21 | } else {
22 | fprintf(stderr, "read failed: %s\n", strerror(errno));
23 | exit(1);
24 | }
25 | }
26 |
27 | // Finalize the hash. BLAKE3_OUT_LEN is the default output length, 32 bytes.
28 | uint8_t output[BLAKE3_OUT_LEN];
29 | blake3_hasher_finalize(&hasher, output, BLAKE3_OUT_LEN);
30 |
31 | // Print the hash as hexadecimal.
32 | for (size_t i = 0; i < BLAKE3_OUT_LEN; i++) {
33 | printf("%02x", output[i]);
34 | }
35 | printf("\n");
36 | return 0;
37 | }
38 |
--------------------------------------------------------------------------------
/vendor/bela/src/belahash/blake3/libblake3.pc.in:
--------------------------------------------------------------------------------
1 | prefix="@CMAKE_INSTALL_PREFIX@"
2 | exec_prefix="${prefix}"
3 | libdir="${prefix}/@CMAKE_INSTALL_LIBDIR@"
4 | includedir="${prefix}/@CMAKE_INSTALL_INCLUDEDIR@"
5 |
6 | Name: @PROJECT_NAME@
7 | Description: @PROJECT_DESCRIPTION@
8 | Version: @PROJECT_VERSION@
9 |
10 | Requires:
11 | Libs: -L"${libdir}" -lblake3
12 | Cflags: -I"${includedir}" @BLAKE3_PKGCONFIG_CFLAGS@
13 |
--------------------------------------------------------------------------------
/vendor/bela/src/belashl/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # bela win libaray
2 |
3 | add_library(belashl STATIC picker.cc)
4 |
5 | target_link_libraries(belashl belawin Comctl32 Ole32)
6 |
7 | if(BELA_ENABLE_LTO)
8 | set_property(TARGET belashl PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
9 | endif()
10 |
--------------------------------------------------------------------------------
/vendor/bela/src/belatime/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | #
2 |
3 | # bela win libaray
4 |
5 | add_library(
6 | belatime STATIC
7 | clock.cc
8 | datetime.cc
9 | dos.cc
10 | duration.cc
11 | format.cc
12 | time.cc
13 | timezone.cc)
14 |
15 | target_link_libraries(belatime bela)
16 |
17 | if(BELA_ENABLE_LTO)
18 | set_property(TARGET belatime PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
19 | endif()
20 |
--------------------------------------------------------------------------------
/vendor/bela/src/belatime/ReadMe.md:
--------------------------------------------------------------------------------
1 | # Time
2 |
3 |
4 | [Leap Smear](https://developers.google.com/time/smear)
5 |
6 | [How the Windows Time service treats a leap second](https://docs.microsoft.com/en-us/troubleshoot/windows-server/identity/time-service-treats-leap-second)
7 |
8 | ## Windows Time
9 |
10 | [How the Windows Time Service Works](https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2003/cc773013(v=ws.10))
--------------------------------------------------------------------------------
/vendor/bela/src/belatime/clock.cc:
--------------------------------------------------------------------------------
1 | ///
2 | #include
3 | #include
4 | #include
5 |
6 | namespace bela {
7 |
8 | // GetCurrentTimeNanos
9 | int64_t GetCurrentTimeNanos() {
10 | using namespace std::chrono;
11 | return duration_cast(system_clock::now().time_since_epoch()).count();
12 | }
13 |
14 | Time Now() {
15 | // TODO(bww): Get a timespec instead so we don't have to divide.
16 | int64_t n = bela::GetCurrentTimeNanos();
17 | if (n >= 0) {
18 | return time_internal::FromUnixDuration(time_internal::MakeDuration(n / 1000000000, n % 1000000000 * 4));
19 | }
20 | return time_internal::FromUnixDuration(bela::Nanoseconds(n));
21 | }
22 | // Returns the maximum duration that SleepOnce() can sleep for.
23 | constexpr bela::Duration MaxSleep() {
24 | #ifdef _WIN32
25 | // Windows Sleep() takes unsigned long argument in milliseconds.
26 | return bela::Milliseconds((std::numeric_limits::max)()); // NOLINT(runtime/int)
27 | #else
28 | return bela::Seconds(std::numeric_limits::max());
29 | #endif
30 | }
31 |
32 | // Sleeps for the given duration.
33 | // REQUIRES: to_sleep <= MaxSleep().
34 | void SleepOnce(bela::Duration to_sleep) {
35 | #ifdef _WIN32
36 | Sleep(static_cast(to_sleep / bela::Milliseconds(1)));
37 | #else
38 | struct timespec sleep_time = bela::ToTimespec(to_sleep);
39 | while (nanosleep(&sleep_time, &sleep_time) != 0 && errno == EINTR) {
40 | // Ignore signals and wait for the full interval to elapse.
41 | }
42 | #endif
43 | }
44 | } // namespace bela
45 |
46 | extern "C" {
47 |
48 | BELA_ATTRIBUTE_WEAK void BelaInternalSleepFor(bela::Duration duration) {
49 | while (duration > bela::ZeroDuration()) {
50 | bela::Duration to_sleep = (std::min)(duration, bela::MaxSleep());
51 | bela::SleepOnce(to_sleep);
52 | duration -= to_sleep;
53 | }
54 | }
55 |
56 | } // extern "C"
--------------------------------------------------------------------------------
/vendor/bela/src/belatime/dos.cc:
--------------------------------------------------------------------------------
1 | ///
2 | #include
3 | #include
4 |
5 | namespace bela {
6 |
7 | constexpr int WindowsEpochDays = (1601 - 1) * 365 + (1601 - 1) / 4 - (1601 - 1) / 100 + (1601 - 1) / 400;
8 | constexpr int64_t UnixEpochStart = 11644473600LL;
9 |
10 | constexpr uint64_t Win_ticks_per_second = 10000000ULL;
11 | constexpr uint64_t Win_ticks_from_epoch = ((1970 - 1601) * 365 + 3 * 24 + 17) * 86400ULL * Win_ticks_per_second;
12 |
13 | constexpr bool IsLeapYear(int Y) { return Y % 4 == 0 && (Y % 100 != 0 || Y % 400 == 0); }
14 | constexpr int sinceWindowsEpochDays(int Y) {
15 | Y--;
16 | return Y * 365 + Y / 4 - Y / 100 + Y / 400 - WindowsEpochDays;
17 | }
18 | // FromDosDateTime dos time to bela::Time
19 | // https://msdn.microsoft.com/en-us/library/ms724247(v=VS.85).aspx
20 | // Windows Epoch start 1601
21 | bela::Time FromDosDateTime(uint16_t dosDate, uint16_t dosTime) {
22 | auto year = (static_cast(dosDate) >> 9) + 1980;
23 | auto mon = static_cast((dosDate >> 5) & 0xf);
24 | auto day = static_cast(dosDate & 0x1f);
25 | auto hour = static_cast(dosTime) >> 11;
26 | auto minute = static_cast((dosTime >> 5) & 0x3f);
27 | auto sec = static_cast(dosTime & 0x1f) << 1;
28 | if (sec < 0 || sec > 59 || minute > 59 || minute < 0 || hour < 0 || hour > 23 || mon < 1 || mon > 12 || year < 1601) {
29 | return bela::UnixEpoch();
30 | }
31 | auto leapYear = IsLeapYear(year);
32 | auto mondays = leapYear ? time_internal::LeapMonths[mon - 1] : time_internal::Months[mon - 1];
33 | if (day < 1 || day > mondays) {
34 | return bela::UnixEpoch();
35 | }
36 | auto days = sinceWindowsEpochDays(year);
37 | for (auto i = 1; i < mon; i++) {
38 | days += time_internal::Months[i - 1];
39 | }
40 | if (mon > 2 && leapYear) {
41 | days++;
42 | }
43 | days += day - 1;
44 | return bela::FromUnixSeconds(days * secondsPerDay + hour * 3600 + minute * 60 + sec - UnixEpochStart);
45 | }
46 | } // namespace bela
--------------------------------------------------------------------------------
/vendor/bela/src/belatime/timezone.cc:
--------------------------------------------------------------------------------
1 | ///
2 | #include
3 | #include
4 | #include
5 |
6 | namespace bela {
7 | // SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones
8 | // https://docs.microsoft.com/en-us/windows/win32/api/timezoneapi/nf-timezoneapi-gettimezoneinformation
9 |
10 | static TIME_ZONE_INFORMATION tz_info;
11 | static std::once_flag tz_flag;
12 |
13 | std::int_least32_t TimeZoneOffset() {
14 | std::call_once(tz_flag, [] { GetTimeZoneInformation(&tz_info); });
15 | return tz_info.Bias * 60;
16 | }
17 |
18 | const wchar_t *TimeZoneStandardName() {
19 | std::call_once(tz_flag, [] { GetTimeZoneInformation(&tz_info); });
20 | return tz_info.StandardName;
21 | }
22 |
23 | } // namespace bela
--------------------------------------------------------------------------------
/vendor/bela/src/belaund/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # bela win libaray
2 |
3 | add_library(
4 | belaund STATIC
5 | llvm/lib/Demangle/Demangle.cpp
6 | llvm/lib/Demangle/DLangDemangle.cpp
7 | llvm/lib/Demangle/ItaniumDemangle.cpp
8 | llvm/lib/Demangle/MicrosoftDemangle.cpp
9 | llvm/lib/Demangle/MicrosoftDemangleNodes.cpp
10 | llvm/lib/Demangle/RustDemangle.cpp)
11 |
12 | if(BELA_ENABLE_LTO)
13 | set_property(TARGET belaund PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
14 | endif()
15 |
16 | target_include_directories(belaund PRIVATE llvm/include)
17 | target_compile_options(belaund PRIVATE -wd4996 -wd4244 -wd4267)
--------------------------------------------------------------------------------
/vendor/bela/src/belaund/llvm/VERSION:
--------------------------------------------------------------------------------
1 | llvm-project:8be07adfb42d8d5d060b807d5445b6fefc949bee
--------------------------------------------------------------------------------
/vendor/bela/src/belaund/llvm/include/llvm/Demangle/ItaniumNodes.def:
--------------------------------------------------------------------------------
1 | //===--- ItaniumNodes.def ------------*- mode:c++;eval:(read-only-mode) -*-===//
2 | // Do not edit! See README.txt.
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 | // See https://llvm.org/LICENSE.txt for license information.
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 | //
7 | //===----------------------------------------------------------------------===//
8 | //
9 | // Define the demangler's node names
10 |
11 | #ifndef NODE
12 | #error Define NODE to handle nodes
13 | #endif
14 |
15 | NODE(NodeArrayNode)
16 | NODE(DotSuffix)
17 | NODE(VendorExtQualType)
18 | NODE(QualType)
19 | NODE(ConversionOperatorType)
20 | NODE(PostfixQualifiedType)
21 | NODE(ElaboratedTypeSpefType)
22 | NODE(NameType)
23 | NODE(AbiTagAttr)
24 | NODE(EnableIfAttr)
25 | NODE(ObjCProtoName)
26 | NODE(PointerType)
27 | NODE(ReferenceType)
28 | NODE(PointerToMemberType)
29 | NODE(ArrayType)
30 | NODE(FunctionType)
31 | NODE(NoexceptSpec)
32 | NODE(DynamicExceptionSpec)
33 | NODE(FunctionEncoding)
34 | NODE(LiteralOperator)
35 | NODE(SpecialName)
36 | NODE(CtorVtableSpecialName)
37 | NODE(QualifiedName)
38 | NODE(NestedName)
39 | NODE(LocalName)
40 | NODE(ModuleName)
41 | NODE(ModuleEntity)
42 | NODE(VectorType)
43 | NODE(PixelVectorType)
44 | NODE(BinaryFPType)
45 | NODE(BitIntType)
46 | NODE(SyntheticTemplateParamName)
47 | NODE(TypeTemplateParamDecl)
48 | NODE(NonTypeTemplateParamDecl)
49 | NODE(TemplateTemplateParamDecl)
50 | NODE(TemplateParamPackDecl)
51 | NODE(ParameterPack)
52 | NODE(TemplateArgumentPack)
53 | NODE(ParameterPackExpansion)
54 | NODE(TemplateArgs)
55 | NODE(ForwardTemplateReference)
56 | NODE(NameWithTemplateArgs)
57 | NODE(GlobalQualifiedName)
58 | NODE(ExpandedSpecialSubstitution)
59 | NODE(SpecialSubstitution)
60 | NODE(CtorDtorName)
61 | NODE(DtorName)
62 | NODE(UnnamedTypeName)
63 | NODE(ClosureTypeName)
64 | NODE(StructuredBindingName)
65 | NODE(BinaryExpr)
66 | NODE(ArraySubscriptExpr)
67 | NODE(PostfixExpr)
68 | NODE(ConditionalExpr)
69 | NODE(MemberExpr)
70 | NODE(SubobjectExpr)
71 | NODE(EnclosingExpr)
72 | NODE(CastExpr)
73 | NODE(SizeofParamPackExpr)
74 | NODE(CallExpr)
75 | NODE(NewExpr)
76 | NODE(DeleteExpr)
77 | NODE(PrefixExpr)
78 | NODE(FunctionParam)
79 | NODE(ConversionExpr)
80 | NODE(PointerToMemberConversionExpr)
81 | NODE(InitListExpr)
82 | NODE(FoldExpr)
83 | NODE(ThrowExpr)
84 | NODE(BoolExpr)
85 | NODE(StringLiteral)
86 | NODE(LambdaExpr)
87 | NODE(EnumLiteral)
88 | NODE(IntegerLiteral)
89 | NODE(FloatLiteral)
90 | NODE(DoubleLiteral)
91 | NODE(LongDoubleLiteral)
92 | NODE(BracedExpr)
93 | NODE(BracedRangeExpr)
94 |
95 | #undef NODE
96 |
--------------------------------------------------------------------------------
/vendor/bela/src/belaund/llvm/include/llvm/Demangle/StringViewExtras.h:
--------------------------------------------------------------------------------
1 | //===--- StringViewExtras.h ----------*- mode:c++;eval:(read-only-mode) -*-===//
2 | // Do not edit! See README.txt.
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 | // See https://llvm.org/LICENSE.txt for license information.
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 | //
7 | //===----------------------------------------------------------------------===//
8 | //
9 | // There are two copies of this file in the source tree. The one under
10 | // libcxxabi is the original and the one under llvm is the copy. Use
11 | // cp-to-llvm.sh to update the copy. See README.txt for more details.
12 | //
13 | //===----------------------------------------------------------------------===//
14 |
15 | #ifndef DEMANGLE_STRINGVIEW_H
16 | #define DEMANGLE_STRINGVIEW_H
17 |
18 | #include "DemangleConfig.h"
19 |
20 | #include
21 |
22 | DEMANGLE_NAMESPACE_BEGIN
23 |
24 | inline bool starts_with(std::string_view self, char C) noexcept {
25 | return !self.empty() && *self.begin() == C;
26 | }
27 |
28 | inline bool starts_with(std::string_view haystack,
29 | std::string_view needle) noexcept {
30 | if (needle.size() > haystack.size())
31 | return false;
32 | haystack.remove_suffix(haystack.size() - needle.size());
33 | return haystack == needle;
34 | }
35 |
36 | DEMANGLE_NAMESPACE_END
37 |
38 | #endif
39 |
--------------------------------------------------------------------------------
/vendor/bela/src/belaund/llvm/lib/Demangle/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_llvm_component_library(LLVMDemangle
2 | Demangle.cpp
3 | ItaniumDemangle.cpp
4 | MicrosoftDemangle.cpp
5 | MicrosoftDemangleNodes.cpp
6 | RustDemangle.cpp
7 | DLangDemangle.cpp
8 |
9 | ADDITIONAL_HEADER_DIRS
10 | "${LLVM_MAIN_INCLUDE_DIR}/llvm/Demangle"
11 |
12 | )
13 |
--------------------------------------------------------------------------------
/vendor/bela/src/belaund/llvm/lib/Demangle/Demangle.cpp:
--------------------------------------------------------------------------------
1 | //===-- Demangle.cpp - Common demangling functions ------------------------===//
2 | //
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 | // See https://llvm.org/LICENSE.txt for license information.
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 | //
7 | //===----------------------------------------------------------------------===//
8 | ///
9 | /// \file This file contains definitions of common demangling functions.
10 | ///
11 | //===----------------------------------------------------------------------===//
12 |
13 | #include "llvm/Demangle/Demangle.h"
14 | #include "llvm/Demangle/StringViewExtras.h"
15 | #include
16 | #include
17 |
18 | using llvm::itanium_demangle::starts_with;
19 |
20 | std::string llvm::demangle(std::string_view MangledName) {
21 | std::string Result;
22 |
23 | if (nonMicrosoftDemangle(MangledName, Result))
24 | return Result;
25 |
26 | if (starts_with(MangledName, '_') &&
27 | nonMicrosoftDemangle(MangledName.substr(1), Result))
28 | return Result;
29 |
30 | if (char *Demangled = microsoftDemangle(MangledName, nullptr, nullptr)) {
31 | Result = Demangled;
32 | std::free(Demangled);
33 | } else {
34 | Result = MangledName;
35 | }
36 | return Result;
37 | }
38 |
39 | static bool isItaniumEncoding(std::string_view S) {
40 | // Itanium encoding requires 1 or 3 leading underscores, followed by 'Z'.
41 | return starts_with(S, "_Z") || starts_with(S, "___Z");
42 | }
43 |
44 | static bool isRustEncoding(std::string_view S) { return starts_with(S, "_R"); }
45 |
46 | static bool isDLangEncoding(std::string_view S) { return starts_with(S, "_D"); }
47 |
48 | bool llvm::nonMicrosoftDemangle(std::string_view MangledName,
49 | std::string &Result) {
50 | char *Demangled = nullptr;
51 | if (isItaniumEncoding(MangledName))
52 | Demangled = itaniumDemangle(MangledName);
53 | else if (isRustEncoding(MangledName))
54 | Demangled = rustDemangle(MangledName);
55 | else if (isDLangEncoding(MangledName))
56 | Demangled = dlangDemangle(MangledName);
57 |
58 | if (!Demangled)
59 | return false;
60 |
61 | Result = Demangled;
62 | std::free(Demangled);
63 | return true;
64 | }
65 |
--------------------------------------------------------------------------------
/vendor/bela/src/belawin/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # bela win libaray
2 |
3 | set(PE_FILES
4 | pe/delayimports.cc
5 | pe/dotnet.cc
6 | pe/exports.cc
7 | pe/file.cc
8 | pe/imports.cc
9 | pe/overlay.cc
10 | pe/resource.cc
11 | pe/rva.cc
12 | pe/searcher.cc
13 | pe/section.cc
14 | pe/string.cc
15 | pe/symbol.cc
16 | pe/version.cc
17 | )
18 |
19 | add_library(
20 | belawin STATIC
21 | env.cc
22 | io.cc
23 | fs.cc
24 | path.cc
25 | process.cc
26 | realpath.cc
27 | simulator.cc
28 | ${PE_FILES})
29 |
30 | target_link_libraries(belawin bela version)
31 |
32 | if(BELA_ENABLE_LTO)
33 | set_property(TARGET belawin PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
34 | endif()
35 |
--------------------------------------------------------------------------------
/vendor/bela/src/belawin/ReadMe.md:
--------------------------------------------------------------------------------
1 | # Bela Windows OS Feature library
--------------------------------------------------------------------------------
/vendor/bela/src/belawin/env.cc:
--------------------------------------------------------------------------------
1 | ///////////
2 | // bela expand env
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | namespace bela {
10 |
11 | // https://docs.microsoft.com/en-us/windows/desktop/api/processenv/nf-processenv-expandenvironmentstringsw
12 | std::wstring WindowsExpandEnv(std::wstring_view sv) {
13 | auto pos = sv.find('%');
14 | if (pos == std::wstring_view::npos) {
15 | return std::wstring(sv);
16 | }
17 | // NO check
18 | if (sv.find(L'%', pos + 1) == std::wstring_view::npos) {
19 | return std::wstring(sv);
20 | }
21 | std::wstring buf;
22 | buf.resize(sv.size() + 256);
23 | auto N = ExpandEnvironmentStringsW(sv.data(), buf.data(), static_cast(buf.size()));
24 | if (static_cast(N) > buf.size()) {
25 | buf.resize(N);
26 | N = ExpandEnvironmentStringsW(sv.data(), buf.data(), static_cast(buf.size()));
27 | }
28 | if (N == 0 || static_cast(N) > buf.size()) {
29 | return L"";
30 | }
31 | buf.resize(N - 1);
32 | return buf;
33 | }
34 |
35 | std::wstring PathUnExpand(std::wstring_view sv) {
36 | constexpr const std::wstring_view envvars[] = {
37 | //--
38 | L"ALLUSERSPROFILE", //
39 | L"APPDATA", //
40 | L"COMPUTERNAME", //
41 | L"ProgramFiles", //
42 | L"SystemRoot", //
43 | L"SystemDrive", //
44 | L"USERPROFILE"
45 | //
46 | };
47 | std::wstring buf;
48 | buf.reserve(sv.size());
49 | auto it = sv.data();
50 | auto end = it + sv.size();
51 | while (it < end) {
52 | auto pos = CharFind(it, end, '%');
53 | if (pos == bela::MaximumPos) {
54 | buf.append(it, end - it);
55 | break;
56 | }
57 | buf.append(it, pos);
58 | it += pos + 1;
59 | if (it >= end) {
60 | break;
61 | }
62 | size_t xlen = end - it;
63 | for (auto e : envvars) {
64 | if (xlen < e.size() + 1) {
65 | continue;
66 | }
67 | if (_wcsnicmp(it, e.data(), e.size()) == 0 && it[e.size()] == '%') {
68 | buf.append(GetEnv(e));
69 | it += e.size() + 1;
70 | }
71 | }
72 | }
73 | return buf;
74 | }
75 | } // namespace bela
76 |
--------------------------------------------------------------------------------
/vendor/bela/src/belawin/pe/internal.hpp:
--------------------------------------------------------------------------------
1 | ///
2 | #ifndef BELA_PE_INTERNAL_HPP
3 | #define BELA_PE_INTERNAL_HPP
4 | #include
5 |
6 | namespace bela::pe {
7 |
8 | struct image_import_descriptor {
9 | uint32_t OriginalFirstThunk;
10 | uint32_t TimeDateStamp;
11 | uint32_t ForwarderChain;
12 | uint32_t Name;
13 | uint32_t FirstThunk;
14 | };
15 |
16 | struct image_delayload_descriptor {
17 | uint32_t Attributes;
18 | uint32_t DllNameRVA;
19 | uint32_t ModuleHandleRVA;
20 | uint32_t ImportAddressTableRVA;
21 | uint32_t ImportNameTableRVA;
22 | uint32_t BoundImportAddressTableRVA;
23 | uint32_t UnloadInformationTableRVA;
24 | uint32_t TimeDateStamp;
25 | };
26 | } // namespace bela::pe
27 |
28 | #endif
--------------------------------------------------------------------------------
/vendor/bela/src/belawin/pe/overlay.cc:
--------------------------------------------------------------------------------
1 | // read pe overlay data
2 | #include "internal.hpp"
3 |
4 | namespace bela::pe {
5 | int64_t File::ReadOverlay(std::span overlayData, bela::error_code &ec) const {
6 | if (size <= overlayOffset) {
7 | ec = bela::make_error_code(ErrNoOverlay, L"no overlay data");
8 | return -1;
9 | }
10 | auto readSize = (std::min)(static_cast(overlayData.size()), size - overlayOffset);
11 | if (!fd.ReadAt(overlayData.subspan(0, static_cast(readSize)), overlayOffset, ec)) {
12 | return -1;
13 | }
14 | return readSize;
15 | }
16 |
17 | } // namespace bela::pe
--------------------------------------------------------------------------------
/vendor/bela/src/belawin/pe/resource.cc:
--------------------------------------------------------------------------------
1 | ///
2 | #include "internal.hpp"
3 |
4 | namespace bela::pe {
5 | struct image_resource_directory {
6 | uint32_t characteristics;
7 | uint32_t time_date_stamp;
8 | uint16_t major_version;
9 | uint16_t minor_version;
10 | uint16_t number_of_named_entries;
11 | uint16_t number_of_id_entries;
12 | // image_resource_directory_entry directory_entries[];
13 | };
14 |
15 | struct image_resource_directory_entry {
16 | union {
17 | struct {
18 | uint32_t name_offset : 31;
19 | uint32_t name_is_string : 1;
20 | };
21 | uint32_t name;
22 | uint16_t id;
23 | };
24 | union {
25 | uint32_t offset_to_data;
26 | struct {
27 | uint32_t offset_to_directory : 31;
28 | uint32_t data_is_directory : 1;
29 | };
30 | };
31 | };
32 |
33 | struct image_resource_directory_string {
34 | uint16_t length;
35 | uint8_t name_string[1];
36 | };
37 |
38 | struct image_resource_dir_string_u {
39 | uint16_t length;
40 | uint16_t name_string[1];
41 | };
42 |
43 | struct image_resource_data_entry {
44 | uint32_t offset_to_data;
45 | uint32_t size;
46 | uint32_t code_page;
47 | uint32_t reserved;
48 | };
49 |
50 | // manifest
51 | constexpr std::string_view rsrcName = ".rsrc";
52 |
53 | std::optional File::LookupVersion(bela::error_code &ec) const {
54 | auto dd = getDataDirectory(IMAGE_DIRECTORY_ENTRY_RESOURCE);
55 | if (dd == nullptr) {
56 | return std::nullopt;
57 | }
58 | if (dd->VirtualAddress == 0) {
59 | return std::nullopt;
60 | }
61 | auto sec = getSection(rsrcName);
62 | if (sec == nullptr) {
63 | return std::nullopt;
64 | }
65 | auto offset = static_cast(sec->Offset);
66 | auto N = dd->VirtualAddress - sec->VirtualAddress;
67 | auto offsetSize = sec->Size - N;
68 | IMAGE_RESOURCE_DIRECTORY ird;
69 | if (!fd.ReadAt(ird, offset, ec)) {
70 | return std::nullopt;
71 | }
72 | auto totalEntries = static_cast(ird.NumberOfNamedEntries) + static_cast(ird.NumberOfIdEntries);
73 | if (totalEntries == 0) {
74 | return std::nullopt;
75 | }
76 | IMAGE_RESOURCE_DIRECTORY_ENTRY entry;
77 | for (auto i = 0; i < totalEntries; i++) {
78 | if (!fd.ReadFull(entry, ec)) {
79 | return std::nullopt;
80 | }
81 | // if (entry.NameIsString != 1) {
82 | // continue;
83 | // }
84 | // if (entry.Name != 0x00000010) {
85 | // }
86 | }
87 | return std::nullopt;
88 | }
89 |
90 | } // namespace bela::pe
--------------------------------------------------------------------------------
/vendor/bela/src/belawin/pe/rva.cc:
--------------------------------------------------------------------------------
1 | //
2 | #include "internal.hpp"
3 |
4 | namespace bela::pe {
5 | // https://docs.microsoft.com/en-us/windows/desktop/Debug/pe-format
6 | // PE32+ executable (console) x86-64, for MS Windows
7 | // PE32 executable (DLL) (console) Intel 80386 Mono/.Net assembly, for MS
8 | // Windows PE32 executable (console) Intel 80386, for MS Windows file command
9 | // not support check arm and arm64
10 | // Not depend DebHelp.dll
11 | // LE endian
12 | [[maybe_unused]] inline PVOID belarva(PVOID m, PVOID b) {
13 | return reinterpret_cast(reinterpret_cast(b) + reinterpret_cast(m));
14 | }
15 |
16 | PIMAGE_SECTION_HEADER
17 | BelaImageRvaToSection(PIMAGE_NT_HEADERS nh, PVOID BaseAddress, ULONG rva) {
18 | (void)BaseAddress;
19 | ULONG count = bela::fromle(nh->FileHeader.NumberOfSections);
20 | PIMAGE_SECTION_HEADER section = IMAGE_FIRST_SECTION(nh);
21 | ULONG va = 0;
22 | while (count-- != 0) {
23 | va = bela::fromle(section->VirtualAddress);
24 | if ((va <= rva) && (rva < va + bela::fromle(section->SizeOfRawData))) {
25 | return section;
26 | }
27 | section++;
28 | }
29 | return nullptr;
30 | }
31 |
32 | // like RtlImageRvaToVa
33 | PVOID
34 | BelaImageRvaToVa(PIMAGE_NT_HEADERS nh, PVOID BaseAddress, ULONG rva, PIMAGE_SECTION_HEADER *sh) {
35 | PIMAGE_SECTION_HEADER section = nullptr;
36 | if (sh != nullptr) {
37 | section = *sh;
38 | }
39 | if ((section == nullptr) || (rva < bela::fromle(section->VirtualAddress)) ||
40 | (rva >= bela::fromle(section->VirtualAddress) + bela::fromle(section->SizeOfRawData))) {
41 | section = BelaImageRvaToSection(nh, BaseAddress, rva);
42 | if (section == nullptr) {
43 | return nullptr;
44 | }
45 | if (sh != nullptr) {
46 | *sh = section;
47 | }
48 | }
49 | auto va = reinterpret_cast(BaseAddress) + rva +
50 | static_cast(bela::fromle(section->PointerToRawData)) -
51 | static_cast(bela::fromle(section->VirtualAddress));
52 | return reinterpret_cast(va);
53 | }
54 |
55 | } // namespace bela::pe
--------------------------------------------------------------------------------
/vendor/bela/src/belawin/pe/section.cc:
--------------------------------------------------------------------------------
1 | //
2 | #include "internal.hpp"
3 | #include
4 |
5 | namespace bela::pe {
6 |
7 | std::string File::sectionFullName(SectionHeader32 &sh) const {
8 | if (sh.Name[0] != '/') {
9 | return std::string(bela::cstring_view(sh.Name));
10 | }
11 | auto slen = bela::cstring_view({sh.Name + 1, sizeof(sh.Name) - 1});
12 | uint32_t offset = 0;
13 | if (auto result = std::from_chars(slen.data(), slen.data() + slen.size(), offset); result.ec != std::errc{}) {
14 | return "";
15 | }
16 | bela::error_code ec;
17 | return std::string(stringTable.make_cstring_view(bela::fromle(offset), ec));
18 | }
19 |
20 | bool File::readRelocs(Section &sec) const {
21 | if (sec.NumberOfRelocations == 0) {
22 | return true;
23 | }
24 | bela::error_code ec;
25 | sec.Relocs.resize(sec.NumberOfRelocations);
26 | if (!fd.ReadAt(sec.Relocs, sec.PointerToRelocations, ec)) {
27 | return false;
28 | }
29 | if constexpr (bela::IsBigEndian()) {
30 | for (auto &reloc : sec.Relocs) {
31 | reloc.VirtualAddress = bela::fromle(reloc.VirtualAddress);
32 | reloc.SymbolTableIndex = bela::fromle(reloc.SymbolTableIndex);
33 | reloc.Type = bela::fromle(reloc.Type);
34 | }
35 | }
36 | return true;
37 | }
38 | std::optional File::readSectionData(const Section &sec, bela::error_code &ec) const {
39 | if (sec.Size == 0) {
40 | return std::make_optional();
41 | }
42 | if (bela::narrow_cast(sec.Offset + sec.Size) > size) {
43 | ec = bela::make_error_code(bela::ErrFileTooSmall, L"corrupted PE file, section overflow file: ", size,
44 | L" section end: ", sec.Offset + sec.Size);
45 | return false;
46 | }
47 | Buffer buffer(sec.Size);
48 | if (!fd.ReadAt(buffer, sec.Size, sec.Offset, ec)) {
49 | ec = bela::make_error_code(ec.code, L"unable read section data: ", ec.message);
50 | return std::nullopt;
51 | }
52 | return std::make_optional(std::move(buffer));
53 | }
54 | } // namespace bela::pe
--------------------------------------------------------------------------------
/vendor/bela/src/belawin/pe/string.cc:
--------------------------------------------------------------------------------
1 | ///
2 | #include "internal.hpp"
3 |
4 | namespace bela::pe {
5 |
6 | bool File::readStringTable(bela::error_code &ec) {
7 | if (fh.PointerToSymbolTable == 0) {
8 | // table nullptr
9 | return true;
10 | }
11 | auto offset = fh.PointerToSymbolTable + COFFSymbolSize * fh.NumberOfSymbols;
12 | if (static_cast(offset + 4) >= size) {
13 | return true;
14 | }
15 | uint32_t l = 0;
16 | if (!fd.ReadAt(l, offset, ec)) {
17 | return false;
18 | }
19 | l = bela::fromle(l);
20 | if (l <= 4 || static_cast(l + offset) > size) {
21 | return true;
22 | }
23 | l -= 4;
24 | bela::Buffer b(l);
25 | if (!fd.ReadFull(b, l, ec)) {
26 | ec = bela::make_error_code(ErrGeneral, L"fail to read string table: ", ec.message);
27 | return false;
28 | }
29 | stringTable.buffer = std::move(b);
30 | return true;
31 | }
32 | } // namespace bela::pe
--------------------------------------------------------------------------------
/vendor/bela/src/hazel/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # bela hazel library
2 |
3 | add_library(
4 | hazel STATIC
5 | ina/archive.cc
6 | ina/binexeobj.cc
7 | ina/docs.cc
8 | ina/font.cc
9 | ina/git.cc
10 | ina/image.cc
11 | ina/media.cc
12 | ina/shebang.cc
13 | ina/shl.cc
14 | ina/text.cc
15 | zip/decompress.cc
16 | zip/filemode.cc
17 | zip/zip.cc
18 | elf/dynamic.cc
19 | elf/elf.cc
20 | elf/gnu.cc
21 | elf/symbol.cc
22 | macho/macho.cc
23 | macho/fat.cc
24 | fs.cc
25 | hazel.cc
26 | mime.cc)
27 |
28 | target_link_libraries(hazel bela belawin)
29 |
30 | if(BELA_ENABLE_LTO)
31 | set_property(TARGET hazel PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
32 | endif()
33 |
--------------------------------------------------------------------------------
/vendor/bela/src/hazel/elf/ReadMe.md:
--------------------------------------------------------------------------------
1 | # ELF documents
2 |
3 | Wikipedia: [Executable and Linkable Format](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format)
4 |
5 | ELF Format image (from: Wikipedia):
6 |
7 | Layout:
8 |
9 | 
10 |
11 | Section:
12 |
13 | 
14 |
15 | ## RISC-V
16 |
17 | [RISC-V ELF psABI specification](https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md)
--------------------------------------------------------------------------------
/vendor/bela/src/hazel/elf/dynamic.cc:
--------------------------------------------------------------------------------
1 | //
2 | #include
3 |
4 | namespace hazel::elf {
5 | bool File::DynString(int tag, std::vector &sv, bela::error_code &ec) const {
6 | if (tag != DT_NEEDED && tag != DT_SONAME && tag != DT_RPATH && tag != DT_RUNPATH) {
7 | ec = bela::make_error_code(ErrGeneral, L"non-string-valued tag ", tag);
8 | return false;
9 | }
10 | auto ds = SectionByType(SHT_DYNAMIC);
11 | if (ds == nullptr) {
12 | return true;
13 | }
14 | bela::Buffer d;
15 | if (!sectionData(*ds, d, ec)) {
16 | return false;
17 | }
18 | bela::Buffer str;
19 | if (!stringTable(ds->Link, str, ec)) {
20 | return false;
21 | }
22 | auto bsv = str.as_bytes_view();
23 | auto dv = d.as_bytes_view();
24 | if (fh.Class == ELFCLASS32) {
25 | while (dv.size() >= 8) {
26 | auto t = cast_from(dv.data());
27 | auto v = cast_from(dv.data() + 4);
28 | dv.remove_prefix(8);
29 | if (static_cast(t) == tag) {
30 | if (auto s = bsv.make_cstring_view(v); !s.empty()) {
31 | sv.emplace_back(s);
32 | }
33 | }
34 | }
35 | return true;
36 | }
37 | while (dv.size() >= 16) {
38 | auto t = cast_from(dv.data());
39 | auto v = cast_from(dv.data() + 8);
40 | dv.remove_prefix(16);
41 | if (static_cast(t) == tag) {
42 | if (auto s = bsv.make_cstring_view(static_cast(v)); !s.empty()) {
43 | sv.emplace_back(s);
44 | }
45 | }
46 | }
47 | return true;
48 | }
49 | } // namespace hazel::elf
--------------------------------------------------------------------------------
/vendor/bela/src/hazel/elf/images/ELF_Executable_and_Linkable_Format_diagram_by_Ange_Albertini.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WildByDesign/AppContainer-Launcher/6f63b1e2dc9e3ddab03c0599bb7d686ec59c046a/vendor/bela/src/hazel/elf/images/ELF_Executable_and_Linkable_Format_diagram_by_Ange_Albertini.png
--------------------------------------------------------------------------------
/vendor/bela/src/hazel/hazel.cc:
--------------------------------------------------------------------------------
1 | //
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include "ina/hazelinc.hpp"
7 |
8 | namespace hazel {
9 |
10 | using lookup_handle_t = hazel::internal::status_t (*)(const bela::bytes_view &, hazel_result &);
11 |
12 | bool LookupBytes(const bela::bytes_view &bv, hazel_result &hr, bela::error_code & /*unused*/) {
13 | if (auto p = memchr(bv.data(), 0, bv.size()); p != nullptr) {
14 | hr.zeroPosition = static_cast(reinterpret_cast(p) - bv.data());
15 | }
16 |
17 | constexpr lookup_handle_t handles[] = {
18 | hazel::internal::LookupExecutableFile, //
19 | hazel::internal::LookupArchives, // 7z ...
20 | hazel::internal::LookupDocs,
21 | hazel::internal::LookupFonts, //
22 | hazel::internal::LookupShellLink, // shortcut
23 | hazel::internal::LookupMedia, // media
24 | hazel::internal::LookupImages, // images
25 | hazel::internal::LookupText,
26 | };
27 | for (auto h : handles) {
28 | if (h(bv, hr) == hazel::internal::Found) {
29 | return true;
30 | }
31 | }
32 | return false;
33 | }
34 |
35 | bool LookupFile(const bela::io::FD &fd, hazel_result &hr, bela::error_code &ec, int64_t offset) {
36 | if ((hr.size_ = fd.Size(ec)) == bela::SizeUnInitialized) {
37 | return false;
38 | }
39 | if (offset < 0 || hr.size_ < offset) {
40 | ec = bela::make_error_code(ErrGeneral, L"file offset over size");
41 | return false;
42 | }
43 | uint8_t buffer[4096];
44 | auto minSize = (std::min)(hr.size_ - offset, 4096LL);
45 | if (!fd.ReadAt({buffer, static_cast(minSize)}, offset, ec)) {
46 | return false;
47 | }
48 | bela::bytes_view bv(buffer, static_cast(minSize));
49 | return LookupBytes(bv, hr, ec);
50 | }
51 |
52 | } // namespace hazel
--------------------------------------------------------------------------------
/vendor/bela/src/hazel/ina/docs.cc:
--------------------------------------------------------------------------------
1 | //////////////
2 | #include "hazelinc.hpp"
3 | #include "docs.hpp"
4 | #include
5 | #include
6 |
7 | namespace hazel::internal {
8 |
9 | // RTF format
10 | // https://en.wikipedia.org/wiki/Rich_Text_Format
11 | /*{\rtf1*/
12 | status_t lookup_rtfinternal(const bela::bytes_view &bv, hazel_result &hr) {
13 | constexpr uint8_t rtfMagic[] = {0x7B, 0x5C, 0x72, 0x74, 0x66};
14 | if (!bv.starts_bytes_with(rtfMagic) || bv.size() < 6) {
15 | return None;
16 | }
17 | // {\rtf1
18 | auto sv = bv.make_string_view(5);
19 | int version = 0;
20 | if (auto result = std::from_chars(sv.data(), sv.data() + sv.size(), version); result.ec != std::errc{}) {
21 | return None;
22 | }
23 | hr.assign(types::rtf, L"Rich Text Format");
24 | hr.append(L"Version", version);
25 | return Found;
26 | }
27 |
28 | // https://en.wikipedia.org/wiki/Compound_File_Binary_Format
29 | // http://www.openoffice.org/sc/compdocfileformat.pdf
30 | // https://interoperability.blob.core.windows.net/files/MS-PPT/[MS-PPT].pdf
31 |
32 | status_t LookupDocs(const bela::bytes_view &bv, hazel_result &hr) {
33 | constexpr const uint8_t msoleMagic[] = {0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1};
34 | if (lookup_rtfinternal(bv, hr) == Found) {
35 | return Found;
36 | }
37 | constexpr const auto olesize = sizeof(oleheader_t);
38 | if (!bv.starts_bytes_with(msoleMagic) || bv.size() < 520) {
39 | return None;
40 | }
41 | if (bv[512] == 0xEC && bv[513] == 0xA5) {
42 | hr.assign(types::doc, L"Microsoft Word 97-2003");
43 | return Found;
44 | }
45 | if (bv[512] == 0x09 && bv[513] == 0x08) {
46 | hr.assign(types::doc, L"Microsoft Excel 97-2003");
47 | return Found;
48 | }
49 | if (bv[512] == 0xA0 && bv[513] == 0x46) {
50 | hr.assign(types::doc, L"Microsoft PowerPoint 97-2003");
51 | return Found;
52 | }
53 | hr.assign(types::msi, L"Windows Installer packages");
54 | return Found;
55 | }
56 | } // namespace hazel::internal
57 |
--------------------------------------------------------------------------------
/vendor/bela/src/hazel/ina/docs.hpp:
--------------------------------------------------------------------------------
1 | ///
2 | #ifndef INQUISITIVE_DOCS_HPP
3 | #define INQUISITIVE_DOCS_HPP
4 | #include
5 |
6 | namespace hazel::internal {
7 | // Microsoft word/ppt/xls
8 | // WordDocument
9 | // https://msdn.microsoft.com/en-us/library/office/dd926131(v=office.12).aspx
10 | // https://msdn.microsoft.com/en-us/library/office/dd949344(v=office.12).aspx
11 | // https://docs.microsoft.com/zh-cn/previous-versions/office/gg615596(v=office.14)
12 | // https://msdn.microsoft.com/en-us/library/cc313154(v=office.12).aspx
13 |
14 | struct oleheader_t {
15 | uint32_t id[2]; // D0CF11E0 A1B11AE1
16 | uint32_t clid[4];
17 | uint16_t verminor; // 0x3e
18 | uint16_t verdll; // 0x03
19 | uint16_t byteorder;
20 | uint16_t lsectorB;
21 | uint16_t lssectorB;
22 |
23 | uint16_t reserved1;
24 | uint32_t reserved2;
25 | uint32_t reserved3;
26 |
27 | uint32_t cfat; // count full sectors
28 | uint32_t dirstart;
29 |
30 | uint32_t reserved4;
31 |
32 | uint32_t sectorcutoff; // min size of a standard stream ; if less than this
33 | // then it uses short-streams
34 | uint32_t sfatstart; // first short-sector or EOC
35 | uint32_t csfat; // count short sectors
36 | uint32_t difstart; // first sector master sector table or EOC
37 | uint32_t cdif; // total count
38 | uint32_t MSAT[109]; // First 109 MSAT
39 | };
40 |
41 | // https://www.oasis-open.org/standards#opendocumentv1.2
42 | } // namespace hazel::internal
43 |
44 | #endif
45 |
--------------------------------------------------------------------------------
/vendor/bela/src/hazel/ina/font.cc:
--------------------------------------------------------------------------------
1 | ////////////// FONT resolve
2 | #include "hazelinc.hpp"
3 |
4 | namespace hazel::internal {
5 |
6 | inline bool IsEot(const bela::bytes_view& bv) {
7 | return bv.size() > 35 && bv[34] == 0x4C && bv[35] == 0x50 &&
8 | ((bv[8] == 0x02 && bv[9] == 0x00 && bv[10] == 0x01) || (bv[8] == 0x01 && bv[9] == 0x00 && bv[10] == 0x00) ||
9 | (bv[8] == 0x02 && bv[9] == 0x00 && bv[10] == 0x02));
10 | }
11 |
12 | status_t LookupFonts(const bela::bytes_view& bv, hazel_result &hr) {
13 | switch (bv[0]) {
14 | case 0x00:
15 | if (bv.size() > 4 && bv[1] == 0x01 && bv[2] == 0x00 && bv[3] == 0x00 && bv[4] == 0x00) {
16 | // https://en.wikipedia.org/wiki/TrueType
17 | hr.assign(types::ttf, L"TrueType Font");
18 | return Found;
19 | }
20 | break;
21 | case 0x4F:
22 | if (bv.size() > 4 && bv[1] == 0x54 && bv[2] == 0x54 && bv[3] == 0x4F && bv[4] == 0x00) {
23 | // https://en.wikipedia.org/wiki/OpenType
24 | hr.assign(types::otf, L"OpenType Font");
25 | return Found;
26 | }
27 | break;
28 | case 0x77:
29 | if (bv.size() <= 7) {
30 | break;
31 | }
32 | if (bv[1] == 0x4F && bv[2] == 0x46 && bv[3] == 0x46 && bv[4] == 0x00 && bv[5] == 0x01 && bv[6] == 0x00 &&
33 | bv[7] == 0x00) {
34 | // https://en.wikipedia.org/wiki/Web_Open_Font_Format
35 | hr.assign(types::woff, L"Web Open Font Format");
36 | return Found;
37 | }
38 | if (bv[1] == 0x4F && bv[2] == 0x46 && bv[3] == 0x32 && bv[4] == 0x00 && bv[5] == 0x01 && bv[6] == 0x00 &&
39 | bv[7] == 0x00) {
40 | // https://en.wikipedia.org/wiki/Web_Open_Font_Format
41 | hr.assign(types::woff2, L"Web Open Font Format 2.0");
42 | return Found;
43 | }
44 | break;
45 | default:
46 | break;
47 | }
48 | if (IsEot(bv)) {
49 | hr.assign(types::eot, L"Embedded OpenType (EOT) fonts");
50 | return Found;
51 | }
52 | return None;
53 | }
54 | } // namespace hazel::internal
--------------------------------------------------------------------------------
/vendor/bela/src/hazel/ina/hazelinc.hpp:
--------------------------------------------------------------------------------
1 | //
2 | #ifndef HAZEL_INTERNAL_INC_HPP
3 | #define HAZEL_INTERNAL_INC_HPP
4 | #include
5 | #include
6 |
7 | namespace hazel::internal {
8 | typedef enum hazel_status_e : int {
9 | None = 0,
10 | Found, ///
11 | Break
12 | } status_t;
13 | status_t LookupExecutableFile(const bela::bytes_view &bv, hazel::hazel_result &hr);
14 | status_t LookupArchives(const bela::bytes_view &bv, hazel::hazel_result &hr);
15 | status_t LookupDocs(const bela::bytes_view &bv, hazel_result &hr);
16 | status_t LookupFonts(const bela::bytes_view &bv, hazel_result &hr);
17 | status_t LookupShellLink(const bela::bytes_view &bv, hazel_result &hr);
18 | status_t LookupMedia(const bela::bytes_view &bv, hazel_result &hr);
19 | status_t LookupImages(const bela::bytes_view &bv, hazel_result &hr);
20 | status_t LookupText(const bela::bytes_view &bv, hazel_result &hr);
21 | bool LookupShebang(const std::wstring_view line, hazel_result &hr);
22 | } // namespace hazel::internal
23 |
24 | #endif
--------------------------------------------------------------------------------
/vendor/bela/src/hazel/macho/ReadMe.md:
--------------------------------------------------------------------------------
1 | # Mach-O documents
2 |
3 | Wikipedia: [Mach-O](https://en.wikipedia.org/wiki/Mach-O)
4 |
5 | Hello Mach-O (source: [http://seriot.ch/hello_macho.php](http://seriot.ch/hello_macho.php)):
6 |
7 | 
8 |
9 | Micro Mach-O (source: [http://seriot.ch/hello_macho.php](http://seriot.ch/hello_macho.php)):
10 |
11 | 
12 |
13 |
--------------------------------------------------------------------------------
/vendor/bela/src/hazel/macho/images/hello-macho.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WildByDesign/AppContainer-Launcher/6f63b1e2dc9e3ddab03c0599bb7d686ec59c046a/vendor/bela/src/hazel/macho/images/hello-macho.jpg
--------------------------------------------------------------------------------
/vendor/bela/src/hazel/macho/images/micro-macho.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WildByDesign/AppContainer-Launcher/6f63b1e2dc9e3ddab03c0599bb7d686ec59c046a/vendor/bela/src/hazel/macho/images/micro-macho.jpg
--------------------------------------------------------------------------------
/vendor/bela/src/hazel/zip/ReadMe.md:
--------------------------------------------------------------------------------
1 | # ZIP
2 |
3 | 
4 |
5 |
6 |
--------------------------------------------------------------------------------
/vendor/bela/src/hazel/zip/decompress.cc:
--------------------------------------------------------------------------------
1 | ///
2 | #include "zipinternal.hpp"
3 | #include
4 |
5 | namespace hazel::zip {
6 | bool Reader::Decompress(const File &file, const Writer &w, bela::error_code &ec) const {
7 | auto realPosition = file.position + baseOffset;
8 | uint8_t buf[fileHeaderLen];
9 | if (!fd.ReadAt(buf, realPosition, ec)) {
10 | return false;
11 | }
12 | bela::endian::LittenEndian b(buf);
13 | if (auto sig = b.Read(); sig != fileHeaderSignature) {
14 | ec = bela::make_error_code(L"zip: not a valid zip file");
15 | return false;
16 | }
17 | b.Discard(22);
18 | auto filenameLen = static_cast(b.Read());
19 | auto extraLen = static_cast(b.Read());
20 | auto position = realPosition + fileHeaderLen + filenameLen + extraLen;
21 | if (!fd.Seek(position, ec)) {
22 | return false;
23 | }
24 | switch (file.method) {
25 | case ZIP_STORE: {
26 | uint8_t buffer[4096];
27 | auto cSize = file.compressed_size;
28 | while (cSize != 0) {
29 | auto minsize = (std::min)(cSize, static_cast(sizeof(buffer)));
30 | if (!fd.ReadFull({buffer, static_cast(minsize)}, ec)) {
31 | return false;
32 | }
33 | if (!w(buffer, static_cast(minsize))) {
34 | return false;
35 | }
36 | cSize -= minsize;
37 | }
38 |
39 | } break;
40 | case ZIP_DEFLATE:
41 | break;
42 | case ZIP_DEFLATE64:
43 | break;
44 | case ZIP_ZSTD:
45 | break;
46 | case ZIP_LZMA2:
47 | break;
48 | case ZIP_PPMD:
49 | break;
50 | case ZIP_XZ:
51 | break;
52 | case ZIP_BZIP2:
53 | break;
54 | default:
55 | ec = bela::make_error_code(ErrGeneral, L"support zip method ", file.method);
56 | return false;
57 | }
58 | return true;
59 | }
60 |
61 | } // namespace hazel::zip
--------------------------------------------------------------------------------
/vendor/bela/src/hazel/zip/filemode.cc:
--------------------------------------------------------------------------------
1 | ///
2 | #include
3 | #include "zipinternal.hpp"
4 |
5 | namespace hazel::zip {
6 | using bela::os::FileMode;
7 | std::string String(FileMode m) {
8 | constexpr const char str[] = "dalTLDpSugct?";
9 | char buf[32] = {0}; //
10 | size_t w = 0;
11 | for (size_t i = 0; i < 13; i++) {
12 | if ((m & (1 << (32 - 1 - i))) != 0) {
13 | buf[w] = str[i];
14 | w++;
15 | }
16 | }
17 | if (w == 0) {
18 | buf[w] = '-';
19 | w++;
20 | }
21 | constexpr const char rwx[] = "rwxrwxrwx";
22 | for (size_t i = 0; i < 11; i++) {
23 | if ((m & (1 << (9 - 1 - i))) != 0) {
24 | buf[w] = rwx[i];
25 | } else {
26 | buf[w] = '-';
27 | }
28 | w++;
29 | }
30 | return std::string{buf, w};
31 | }
32 |
33 | FileMode unixModeToFileMode(uint32_t m) {
34 | uint32_t mode = static_cast(m & 0777);
35 | switch (m & s_IFMT) {
36 | case s_IFBLK:
37 | mode |= FileMode::ModeDevice;
38 | break;
39 | case s_IFCHR:
40 | mode |= FileMode::ModeDevice | FileMode::ModeCharDevice;
41 | break;
42 | case s_IFDIR:
43 | mode |= FileMode::ModeDir;
44 | break;
45 | case s_IFIFO:
46 | mode |= FileMode::ModeNamedPipe;
47 | break;
48 | case s_IFLNK:
49 | mode |= FileMode::ModeSymlink;
50 | break;
51 | case s_IFREG:
52 | break;
53 | case s_IFSOCK:
54 | mode |= FileMode::ModeSocket;
55 | break;
56 | default:
57 | break;
58 | }
59 | if ((m & s_ISGID) != 0) {
60 | mode |= FileMode::ModeSetgid;
61 | }
62 | if ((m & s_ISUID) != 0) {
63 | mode |= FileMode::ModeSetuid;
64 | }
65 | if ((m & s_ISVTX) != 0) {
66 | mode |= FileMode::ModeSticky;
67 | }
68 | return static_cast(mode);
69 | }
70 |
71 | FileMode msdosModeToFileMode(uint32_t m) {
72 | uint32_t mode = 0;
73 | if ((m & msdosDir) != 0) {
74 | mode = FileMode::ModeDir | 0777;
75 | } else {
76 | mode = 0666;
77 | }
78 | if ((m & msdosReadOnly) != 0) {
79 | mode &= ~0222;
80 | }
81 | return static_cast(mode);
82 | }
83 |
84 | FileMode resolveFileMode(const File &file, uint32_t externalAttrs) {
85 | auto mode = static_cast(0);
86 | auto n = file.version_madeby >> 8;
87 | if (n == creatorUnix || n == creatorMacOSX) {
88 | mode = unixModeToFileMode(externalAttrs >> 16);
89 | } else if (n == creatorNTFS || n == creatorVFAT || n == creatorFAT) {
90 | mode = msdosModeToFileMode(externalAttrs);
91 | }
92 | if (file.name.ends_with('/') || file.name.ends_with('\\')) {
93 | mode = mode | FileMode::ModeDir;
94 | }
95 | return mode;
96 | }
97 | } // namespace hazel::zip
--------------------------------------------------------------------------------
/vendor/bela/test/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | #
2 |
3 | add_subdirectory(appexeclink)
4 | add_subdirectory(base)
5 | add_subdirectory(binview)
6 | add_subdirectory(color)
7 | add_subdirectory(escape)
8 | add_subdirectory(escapeargv)
9 | add_subdirectory(filehash)
10 | add_subdirectory(fmt)
11 | add_subdirectory(hazel)
12 | add_subdirectory(io)
13 | add_subdirectory(ls)
14 | add_subdirectory(mix)
15 | add_subdirectory(now)
16 | add_subdirectory(semver)
17 | add_subdirectory(tokencmd)
18 | add_subdirectory(winutils)
19 | add_subdirectory(win)
20 |
--------------------------------------------------------------------------------
/vendor/bela/test/appexeclink/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | #
2 |
3 | add_executable(appexeclink_test appexeclink.cc)
4 |
5 | target_link_libraries(appexeclink_test belawin)
6 |
7 | add_executable(rptest rptest.cc)
8 |
9 | target_link_libraries(rptest belawin hazel)
10 |
11 | add_executable(fileview_test fv.cc)
12 |
13 | target_link_libraries(fileview_test belawin belatime hazel)
14 |
--------------------------------------------------------------------------------
/vendor/bela/test/appexeclink/appexeclink.cc:
--------------------------------------------------------------------------------
1 | ///
2 | #include
3 | #include
4 | // test\appexeclink\appexeclink_test.exe
5 | // C:\Users\$Username\AppData\Local\Microsoft\WindowsApps\wt.exe
6 | int wmain(int argc, wchar_t **argv) {
7 | if (argc < 2) {
8 | bela::FPrintF(stderr, L"usage: %s appexeclink\n", argv[0]);
9 | return 1;
10 | }
11 | bela::error_code ec;
12 | auto p = bela::RealPath(argv[1], ec);
13 | if (p) {
14 | bela::FPrintF(stdout, L"%s RealPath [%s]\n", argv[1], *p);
15 | } else {
16 | bela::FPrintF(stderr, L"%s RealPath error: %s\n", argv[1], ec);
17 | }
18 | auto p2 = bela::RealPathEx(argv[1], ec);
19 | if (p2) {
20 | bela::FPrintF(stdout, L"%s RealPathEx [%s]\n", argv[1], *p2);
21 | } else {
22 | bela::FPrintF(stderr, L"%s RealPathEx error: %s\n", argv[1], ec);
23 | }
24 | bela::AppExecTarget ae;
25 | if (!bela::LookupAppExecLinkTarget(argv[1], ae)) {
26 | bela::FPrintF(stderr, L"unable lookup %s AppExecTarget\n", argv[1]);
27 | return 1;
28 | }
29 | bela::FPrintF(stdout, L"AppExecLink details:\nPackageID: %s\nAppUserID: %s\nTarget: %s\n", ae.pkid,
30 | ae.appuserid, ae.target);
31 | return 0;
32 | }
--------------------------------------------------------------------------------
/vendor/bela/test/appexeclink/rptest.cc:
--------------------------------------------------------------------------------
1 | // Test reparse pointer
2 |
3 | #include
4 | #include
5 |
6 | int wmain(int argc, wchar_t **argv) {
7 | if (argc < 2) {
8 | bela::FPrintF(stderr, L"usage: %s path\n", argv[0]);
9 | return 1;
10 | }
11 | hazel::fs::FileReparsePoint frp;
12 | bela::error_code ec;
13 | if (!hazel::fs::LookupReparsePoint(argv[1], frp, ec)) {
14 | bela::FPrintF(stderr, L"unable lookup reparse point %s\n", ec);
15 | return 1;
16 | }
17 | for (auto &kv : frp.attributes) {
18 | bela::FPrintF(stderr, L"%s: %s\n", kv.first, kv.second);
19 | }
20 | return 0;
21 | }
--------------------------------------------------------------------------------
/vendor/bela/test/base/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # base
2 | add_executable(base_test
3 | base.cc
4 | )
5 |
6 | target_link_libraries(base_test
7 | bela
8 | )
9 |
10 | # base
11 | add_executable(cityhash_test
12 | cityhash.cc
13 | )
14 |
15 | target_link_libraries(cityhash_test
16 | bela
17 | )
18 |
19 |
20 | # base
21 | add_executable(ascii_test
22 | ascii.cc
23 | )
24 |
25 | target_link_libraries(ascii_test
26 | bela
27 | )
28 |
29 | # base
30 | add_executable(fnmatch_test
31 | fnmatch.cc
32 | )
33 |
34 | target_link_libraries(fnmatch_test
35 | bela
36 | )
37 |
38 | # delfile
39 | add_executable(delfile_test
40 | delfile.cc
41 | )
42 |
43 | target_link_libraries(delfile_test
44 | bela
45 | belawin
46 | )
47 |
48 | # base
49 | add_executable(strsplit_test
50 | strsplit.cc
51 | )
52 |
53 | target_link_libraries(strsplit_test
54 | bela
55 | )
56 |
57 |
58 |
59 | # base
60 | add_executable(startswith_test
61 | startswith.cc
62 | )
63 |
64 | target_link_libraries(startswith_test
65 | bela
66 | )
67 |
68 | # base
69 | add_executable(static_string_test
70 | static_string.cc
71 | )
72 |
73 | target_link_libraries(static_string_test
74 | bela
75 | )
76 |
77 | add_executable(iota_test
78 | iota.cc
79 | )
80 |
81 | target_link_libraries(iota_test
82 | bela
83 | )
84 |
85 | add_executable(strings_cat_test
86 | strings_cat.cc
87 | )
88 |
89 | target_link_libraries(strings_cat_test
90 | bela
91 | )
--------------------------------------------------------------------------------
/vendor/bela/test/base/cityhash.cc:
--------------------------------------------------------------------------------
1 | //
2 | #include
3 | #include
4 |
5 | int wmain(int argc, wchar_t **argv) {
6 | std::wstring_view sn(argv[0]);
7 | bela::FPrintF(stderr, L"%s --> hash: %d\n", argv[0],
8 | bela::CityHash64(reinterpret_cast(sn.data()), sn.size() * sizeof(wchar_t)));
9 | return 0;
10 | }
--------------------------------------------------------------------------------
/vendor/bela/test/base/constexpr_base.cc:
--------------------------------------------------------------------------------
1 | ///
2 | #include
3 | //#include
4 |
5 | int wmain() {
6 | constexpr bela::Hex a(123456789U);
7 | constexpr bela::Dec b(123456789, bela::kZeroPad16);
8 | return 0;
9 | }
--------------------------------------------------------------------------------
/vendor/bela/test/base/delfile.cc:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | int wmain(int argc, wchar_t **argv) {
6 | if (argc < 2) {
7 | bela::FPrintF(stderr, L"usage: delfile %s\n", argv[0]);
8 | return 1;
9 | }
10 | bela::error_code ec;
11 | if (!bela::fs::ForceDeleteFolders(argv[1], ec)) {
12 | bela::FPrintF(stderr, L"remove all: %s %d %s\n", argv[1], ec.code, ec);
13 | }
14 | return 0;
15 | }
--------------------------------------------------------------------------------
/vendor/bela/test/base/startswith.cc:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | struct kv {
5 | const wchar_t *a;
6 | const wchar_t *b;
7 | };
8 |
9 | int wmain() {
10 | constexpr const kv kvv[] = {
11 | {L"jack", L"kj"}, {L"mmmvn", L"mv"}, {L"helloworld", L"he"},
12 | {L"world", L""}, {L"xxxxwwe3we", L"x"}, {L"xxxmmmv", L"mv"},
13 | };
14 |
15 | for (const auto &k : kvv) {
16 | bela::FPrintF(stderr, L"%s startswith %s %v\n", k.a, k.b, bela::StartsWith(k.a, k.b));
17 | bela::FPrintF(stderr, L"%s endswith %s %v\n", k.a, k.b, bela::EndsWith(k.a, k.b));
18 | }
19 | return 0;
20 | }
--------------------------------------------------------------------------------
/vendor/bela/test/base/static_string.cc:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | int main() {
6 | bela::static_string<4096> exe;
7 | bela::FPrintF(stderr, L"%zu %zu max_size: %zu sv: %s\n", exe.size(), exe.capacity(), exe.max_size(), exe.subview());
8 | //
9 | return 0;
10 | }
--------------------------------------------------------------------------------
/vendor/bela/test/base/strsplit.cc:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | int wmain() {
9 | const wchar_t *paths[] = {
10 | L"/////////////Temp/bela/build",
11 | };
12 | for (const auto p : paths) {
13 | std::vector pvv = bela::StrSplit(p, bela::ByChar('/'), bela::SkipEmpty());
14 | bela::FPrintF(stderr, L"path: %s\n", p);
15 | for (const auto e : pvv) {
16 | bela::FPrintF(stderr, L" %s\n", e);
17 | }
18 | bela::FPrintF(stderr, L"Join: %s\n", bela::StrJoin(pvv, L"/"));
19 | }
20 | const char *Apaths[] = {
21 | "/////////////Temp/bela/build",
22 | };
23 | for (const auto p : Apaths) {
24 | std::vector pvv = bela::narrow::StrSplit(p, bela::narrow::ByChar('/'), bela::narrow::SkipEmpty());
25 | bela::FPrintF(stderr, L"path: %s\n", p);
26 | for (const auto e : pvv) {
27 | bela::FPrintF(stderr, L" %s\n", e);
28 | }
29 | bela::FPrintF(stderr, L"Join: %s\n", bela::narrow::StrJoin(pvv, "/"));
30 | }
31 | bela::FPrintF(stderr, L"%s\n", bela::StrReplaceAll("++++++++++++++++++++dexxxABCdefg", {{"de", "xx"}}));
32 | bela::FPrintF(stderr, L"%s\n", bela::StrReplaceAll(L"wwwwwwwwwwwwwwwwde~~~~~~~~~~~~ABCdefg", {{L"de", L"xx"}}));
33 | return 0;
34 | }
--------------------------------------------------------------------------------
/vendor/bela/test/binview/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # base
2 | add_executable(elfview_test
3 | elfview.cc
4 | )
5 |
6 | target_link_libraries(elfview_test
7 | hazel
8 | belaund
9 | )
10 |
11 | # base
12 | add_executable(machoview_test
13 | machoview.cc
14 | )
15 |
16 | target_link_libraries(machoview_test
17 | hazel
18 | belaund
19 | )
--------------------------------------------------------------------------------
/vendor/bela/test/binview/elfview.cc:
--------------------------------------------------------------------------------
1 | ///
2 | #include
3 | #include
4 | #include
5 |
6 | int wmain(int argc, wchar_t **argv) {
7 | if (argc < 2) {
8 | bela::FPrintF(stderr, L"usage: %s elf-file\n", argv[0]);
9 | return 1;
10 | }
11 | hazel::elf::File file;
12 | bela::error_code ec;
13 | if (!file.NewFile(argv[1], ec)) {
14 | bela::FPrintF(stderr, L"parse elf file %s error: %s\n", argv[1], ec);
15 | return 1;
16 | }
17 | for (const auto &s : file.Sections()) {
18 | bela::FPrintF(stdout, L"%s: %08x (%d) %d %d\n", s.Name, s.Addr, s.Size, s.Entsize, s.Flags);
19 | }
20 | if (auto so = file.LibSoName(ec); so) {
21 | bela::FPrintF(stdout, L"SONAME: %s\n", *so);
22 | }
23 | if (auto rpath = file.Rpath(ec); rpath) {
24 | bela::FPrintF(stdout, L"RPATH: %s\n", *rpath);
25 | }
26 | if (auto rupath = file.Rupath(ec); rupath) {
27 | bela::FPrintF(stdout, L"RUPATH: %s\n", *rupath);
28 | }
29 | std::vector libs;
30 | if (!file.Depends(libs, ec)) {
31 | bela::FPrintF(stderr, L"parse elf file depends %s error: %s\n", argv[1], ec);
32 | return 1;
33 | }
34 | for (const auto &d : libs) {
35 | bela::FPrintF(stdout, L"need: %s\n", d);
36 | }
37 |
38 | if (std::vector symbols; file.Symbols(symbols, ec)) {
39 | bela::FPrintF(stdout, L"\x1b[34mSymbols:\x1b[0m\n");
40 | for (const auto &s : symbols) {
41 | bela::FPrintF(stdout, L"%s %s %s\n", bela::demangle(s.Name), s.Library, s.Version);
42 | }
43 | }
44 |
45 | if (std::vector symbols; file.DynamicSymbols(symbols, ec)) {
46 | bela::FPrintF(stderr, L"\x1b[34mDynamic Symbols:\x1b[0m\n");
47 | for (const auto &s : symbols) {
48 | bela::FPrintF(stdout, L"%s (%s@%s)\n", bela::demangle(s.Name), s.Library, s.Version);
49 | }
50 | }
51 |
52 | if (std::vector symbols; file.ImportedSymbols(symbols, ec)) {
53 | bela::FPrintF(stdout, L"\x1b[34mImported Symbols:\x1b[0m\n");
54 | for (const auto &s : symbols) {
55 | bela::FPrintF(stdout, L"%s (%s@%s)\n", bela::demangle(s.Name), s.Library, s.Version);
56 | }
57 | }
58 |
59 | return 0;
60 | }
--------------------------------------------------------------------------------
/vendor/bela/test/binview/machoview.cc:
--------------------------------------------------------------------------------
1 | ///
2 | #include
3 | #include
4 | #include
5 |
6 | int wmain(int argc, wchar_t **argv) {
7 | if (argc < 2) {
8 | bela::FPrintF(stderr, L"usage: %s macho-o-file\n", argv[0]);
9 | return 1;
10 | }
11 | hazel::macho::File file;
12 | bela::error_code ec;
13 | if (!file.NewFile(argv[1], ec)) {
14 | bela::FPrintF(stderr, L"parse macho file %s error: %s\n", argv[1], ec);
15 | return 1;
16 | }
17 | std::vector libs;
18 | file.Depends(libs, ec);
19 | for (const auto &d : libs) {
20 | bela::FPrintF(stdout, L"need: %s\n", d);
21 | }
22 | std::vector symbols;
23 | if (!file.ImportedSymbols(symbols, ec)) {
24 | bela::FPrintF(stderr, L"parse macho file %s error: %s\n", argv[1], ec);
25 | return 1;
26 | }
27 | for (const auto &s : symbols) {
28 | bela::FPrintF(stdout, L"S: %s\n", bela::demangle(s));
29 | }
30 | return 0;
31 | }
--------------------------------------------------------------------------------
/vendor/bela/test/color/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # base
2 | add_executable(color_test
3 | main.cc
4 | )
5 |
6 | target_link_libraries(color_test
7 | bela
8 | )
--------------------------------------------------------------------------------
/vendor/bela/test/color/main.cc:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | int wmain() {
5 | //
6 | if (auto c1 = bela::color::decode(L"#88FFFF"); c1 == bela::color(0x88, 0xff, 0xff)) {
7 | bela::FPrintF(stderr, L"#88FFFF: r %d g %d b %d: %s\n", c1.r, c1.g, c1.b, c1.encode());
8 | }
9 | if (auto c2 = bela::color::decode(L"#FFFF42FF"); c2 == bela::color(0xff, 0xff, 0x42, 0xff)) {
10 | bela::FPrintF(stderr, L"#FFFF42FF: r %d g %d b %d: %s\n", c2.r, c2.g, c2.b, c2.encode(true));
11 | }
12 | bela::color c(132, 122, 64);
13 | bela::FPrintF(stderr, L"Encode -> %s\n", c.encode