Skip to content

Commit

Permalink
winhandler: catch overflow exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
longjunyu2 committed Aug 6, 2024
1 parent cae178e commit 27683f3
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions app/src/main/java/com/winlator/winhandler/WinHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,17 @@ public void bringToFront(final String processName) {
public void bringToFront(final String processName, final long handle) {
addAction(() -> {
sendData.rewind();
sendData.put(RequestCodes.BRING_TO_FRONT);
byte[] bytes = processName.getBytes();
sendData.putInt(bytes.length);
sendData.put(bytes);
sendData.putLong(handle);
try {
sendData.put(RequestCodes.BRING_TO_FRONT);
byte[] bytes = processName.getBytes();
sendData.putInt(bytes.length);
// FIXME: Chinese and Japanese got from winhandler.exe are broken, and they cause overflow.
sendData.put(bytes);
sendData.putLong(handle);
} catch (java.nio.BufferOverflowException e) {
e.printStackTrace();
sendData.rewind();
}
sendPacket(CLIENT_PORT);
});
}
Expand Down

0 comments on commit 27683f3

Please sign in to comment.