inwc3 / wc3libs

Java library for reading and modifying Warcraft III maps and game files
Apache License 2.0
31 stars 11 forks source link

Refactor PE parser and rewrite WMIC .exe version extraction #79

Closed Luashine closed 2 years ago

Luashine commented 2 years ago

The PE version extraction was refactored. dorkbox Parser was moved to its own class behind an interface. The WMIC extractor was reworked to call wmic.exe directly without creating temporary files, that should avoid potential issues with AV software and be faster.

Tests added that rely on local java.exe and cmd.exe. Update: At last I made a C# binary with the version info: https://github.com/Luashine/dotnet-pe-version

Completely removed the cmd.exe/java.exe tests and now only use the embedded file. The WMIC test is skipped on non-Windows.


It's been a while since I last touched Java, I'd love to hear feedback and a review.

I wanted to tackle #62 so this is part 1 basically. Probably overengineered the IO part of WMIC (just a tiny bit :P). When I tried to reenable GameExeTest, it throws an exception on my system. I will continue in #62

Frotty commented 2 years ago

Nice. I personally didn't care enough to fix this, because you just need to set a manual path once, but it would still be nice to have. Will check and test locally later. I see you are contributing to various open source wc3 projects, cool πŸ‘

codecov-commenter commented 2 years ago

Codecov Report

Merging #79 (5615c85) into master (d105145) will decrease coverage by 0.11%. The diff coverage is 4.16%.

@@             Coverage Diff              @@
##             master      #79      +/-   ##
============================================
- Coverage     40.96%   40.85%   -0.12%     
- Complexity     1722     1724       +2     
============================================
  Files           432      437       +5     
  Lines         21996    22066      +70     
  Branches       1821     1824       +3     
============================================
+ Hits           9010     9014       +4     
- Misses        12437    12502      +65     
- Partials        549      550       +1     
Impacted Files Coverage Ξ”
.../java/net/moonlightflower/wc3libs/bin/GameExe.java 0.00% <0.00%> (ΓΈ)
.../misc/exeversion/CallableInputStreamProcessor.java 0.00% <0.00%> (ΓΈ)
...ightflower/wc3libs/misc/exeversion/ExeVersion.java 0.00% <0.00%> (ΓΈ)
...flower/wc3libs/misc/exeversion/ExeVersionWmic.java 0.00% <0.00%> (ΓΈ)
...bs/misc/exeversion/VersionExtractionException.java 0.00% <0.00%> (ΓΈ)
...htflower/wc3libs/misc/exeversion/ExeVersionPe.java 44.44% <44.44%> (ΓΈ)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Luashine commented 2 years ago

src/test/java/wc3libs/bin/GameExeTest.java That test still fails for me (#62), I will fix it after this PR

Frotty commented 2 years ago

Nice πŸ‘