Skip to content

Commit

Permalink
Removed overlay for faster Gradle builds (+ prepare to replace with D…
Browse files Browse the repository at this point in the history
…irectX direct draw overlay in future)
  • Loading branch information
Jire committed Dec 30, 2022
1 parent 5131191 commit 17a4709
Show file tree
Hide file tree
Showing 22 changed files with 69 additions and 684 deletions.
2 changes: 1 addition & 1 deletion .idea/modules/Overwatcheat.main.iml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .idea/modules/Overwatcheat.test.iml

Large diffs are not rendered by default.

37 changes: 19 additions & 18 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import com.github.jengelman.gradle.plugins.shadow.ShadowApplicationPlugin.SHADOW_INSTALL_TASK_NAME
import com.github.jengelman.gradle.plugins.shadow.ShadowApplicationPlugin.SHADOW_SCRIPTS_TASK_NAME
import org.jetbrains.kotlin.incremental.deleteRecursivelyOrThrow

Expand All @@ -19,42 +20,33 @@ kotlin {
}

dependencies {
implementation(libs.slf4j.api)
runtimeOnly(libs.slf4j.simple)

implementation(libs.fastutil)
implementation(libs.javacv.platform)
implementation(libs.vis.ui)

implementation(libs.affinity)
implementation(libs.chronicle.core)

implementation(libs.jna)
implementation(libs.jna.platform)

implementation(libs.gdx)
implementation(libs.gdx.platform)

implementation(libs.gdx.box2d)
implementation(libs.gdx.box2d.platform)

implementation(libs.gdx.freetype)
implementation(libs.gdx.freetype.platform)

implementation(libs.gdx.backend.lwjgl3)

implementation(libs.slf4j.api)
runtimeOnly(libs.slf4j.simple)
}

application {
applicationName = "Overwatcheat"
mainClass.set("org.jire.overwatcheat.Main")
applicationDefaultJvmArgs += arrayOf(
"-Xmx8g",
"-Xmx4g -Xms1g",

"--enable-native-access=ALL-UNNAMED",
"--add-opens=java.base/java.time=ALL-UNNAMED",
"--add-exports=java.base/sun.nio.ch=ALL-UNNAMED",

"--add-opens=java.base/java.lang=ALL-UNNAMED",
"--add-opens=java.base/java.lang.reflect=ALL-UNNAMED",
"--add-opens=java.base/java.io=ALL-UNNAMED",
"--add-opens=java.base/java.time=ALL-UNNAMED",

"--add-exports=java.base/sun.nio.ch=ALL-UNNAMED",
"--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED"
)
}
Expand Down Expand Up @@ -82,6 +74,15 @@ fun TaskContainerScope.configureShadowJar() {
named<CreateStartScripts>(SHADOW_SCRIPTS_TASK_NAME).configure {
enabled = false
}
named(SHADOW_INSTALL_TASK_NAME).configure {
enabled = false
}
named("shadowDistTar").configure {
enabled = false
}
named("shadowDistZip").configure {
enabled = false
}
}

fun TaskContainerScope.configureOverwatcheat() {
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
org.gradle.jvmargs=-Xmx8g
org.gradle.jvmargs=-Xmx8g -Xms8g
org.gradle.warning.mode=all
3 changes: 0 additions & 3 deletions overwatcheat.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ flick_shoot_pixels=5
# Time off between flick shots (200 for McCree, 350 for Ashe, 270 for Widow)
flick_pause_duration=200

# Whether or not to use the OpenGL overlay.
enable_overlay=false

# Whether or not to toggle in-game UI for better accuracy when holding the aim key.
toggle_in_game_ui=true

Expand Down
8 changes: 4 additions & 4 deletions src/main/kotlin/org/jire/overwatcheat/Keyboard.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
package org.jire.overwatcheat

import org.jire.overwatcheat.nativelib.User32Panama
import org.jire.overwatcheat.nativelib.interception.Interception.interceptionContext
import org.jire.overwatcheat.nativelib.interception.Interception.interception_send
import org.jire.overwatcheat.nativelib.interception.InterceptionKeyState
import org.jire.overwatcheat.nativelib.interception.InterceptionPanama.context
import org.jire.overwatcheat.nativelib.interception.InterceptionPanama.interception_send
import java.lang.foreign.MemorySegment
import java.lang.foreign.MemorySession
import java.lang.foreign.ValueLayout
Expand All @@ -46,15 +46,15 @@ object Keyboard {
set(ValueLayout.JAVA_SHORT, 0, key.toShort())
set(ValueLayout.JAVA_SHORT, 2, InterceptionKeyState.INTERCEPTION_KEY_DOWN.toShort())
}
interception_send(context, deviceId, keyStroke, 1)
interception_send(interceptionContext, deviceId, keyStroke, 1)
}

fun releaseKey(key: Int, deviceId: Int) {
keyStroke.run {
set(ValueLayout.JAVA_SHORT, 0, key.toShort())
set(ValueLayout.JAVA_SHORT, 2, InterceptionKeyState.INTERCEPTION_KEY_UP.toShort())
}
interception_send(context, deviceId, keyStroke, 1)
interception_send(interceptionContext, deviceId, keyStroke, 1)
}

}
Expand Down
5 changes: 0 additions & 5 deletions src/main/kotlin/org/jire/overwatcheat/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import org.jire.overwatcheat.framegrab.FrameGrabber
import org.jire.overwatcheat.framegrab.FrameGrabberThread
import org.jire.overwatcheat.framegrab.FrameHandler
import org.jire.overwatcheat.nativelib.Kernel32
import org.jire.overwatcheat.overlay.OverlayManager
import org.jire.overwatcheat.settings.Settings
import org.jire.overwatcheat.util.PreciseSleeper

Expand Down Expand Up @@ -86,10 +85,6 @@ object Main {
frameGrabberThread.start()
toggleUIThread.start()
aimBotThread.start()

if (Settings.enableOverlay) {
OverlayManager.open(captureOffsetX, captureOffsetY)
}
}

}
12 changes: 6 additions & 6 deletions src/main/kotlin/org/jire/overwatcheat/Mouse.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

package org.jire.overwatcheat

import org.jire.overwatcheat.nativelib.interception.Interception.interceptionContext
import org.jire.overwatcheat.nativelib.interception.Interception.interceptionMouseStrokeLayout
import org.jire.overwatcheat.nativelib.interception.Interception.interception_send
import org.jire.overwatcheat.nativelib.interception.InterceptionFilter
import org.jire.overwatcheat.nativelib.interception.InterceptionMouseFlag
import org.jire.overwatcheat.nativelib.interception.InterceptionPanama.context
import org.jire.overwatcheat.nativelib.interception.InterceptionPanama.interceptionMouseStrokeLayout
import org.jire.overwatcheat.nativelib.interception.InterceptionPanama.interception_send
import java.lang.Thread.sleep
import java.lang.foreign.MemorySegment
import java.lang.foreign.MemorySession
Expand All @@ -49,7 +49,7 @@ object Mouse {
set(ValueLayout.JAVA_INT, 8, x)
set(ValueLayout.JAVA_INT, 12, y)
}
interception_send(context, deviceID, mouseStroke, 1)
interception_send(interceptionContext, deviceID, mouseStroke, 1)
}

fun click(deviceID: Int) {
Expand All @@ -58,10 +58,10 @@ object Mouse {
set(ValueLayout.JAVA_INT, 8, 0)
set(ValueLayout.JAVA_INT, 12, 0)
}
interception_send(context, deviceID, mouseStroke, 1)
interception_send(interceptionContext, deviceID, mouseStroke, 1)
sleep(300)
mouseStroke.set(ValueLayout.JAVA_INT, 0, InterceptionFilter.INTERCEPTION_MOUSE_LEFT_BUTTON_UP)
interception_send(context, deviceID, mouseStroke, 1)
interception_send(interceptionContext, deviceID, mouseStroke, 1)
}

}
29 changes: 2 additions & 27 deletions src/main/kotlin/org/jire/overwatcheat/nativelib/User32.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,11 @@ package org.jire.overwatcheat.nativelib

import com.sun.jna.Pointer
import com.sun.jna.platform.win32.WinUser
import com.sun.jna.ptr.IntByReference
import com.sun.jna.win32.StdCallLibrary
import org.jire.overwatcheat.overlay.transparency.WindowCompositionAttributeData

object User32 : DirectNativeLib("user32") {

external fun GetKeyState(nVirtKey: Int): Short
external fun mouse_event(dwFlags: Int, dx: Int, dy: Int, dwData: Int, dwExtraInfo: Long)
external fun SetWindowDisplayAffinity(window: Pointer, affinity: Int): Boolean
external fun EnumWindows(lpEnumFunc: WinUser.WNDENUMPROC, userData: Pointer?): Boolean
external fun GetWindowTextA(hWnd: Pointer, lpString: ByteArray, nMaxCount: Int): Int
external fun GetWindow(hWnd: Pointer, uCmd: Int): Pointer

interface WndEnumProc : StdCallLibrary.StdCallCallback {
fun callback(hwnd: Long): Boolean
}

external fun SetWindowCompositionAttribute(hwnd: Long, data: WindowCompositionAttributeData): Long
external fun SetWindowDisplayAffinity(hwnd: Long, dwAffinity: Long): Boolean
external fun SetActiveWindow(hwnd: Long): Long
external fun FindWindowA(s: String?, s1: String?): Long
external fun GetWindowLongA(hwnd: Long, i: Int): Int
external fun SetWindowLongA(hwnd: Long, i: Int, i1: Int): Int
external fun SetWindowPos(hwnd: Long, hwnd1: Long, i: Int, i1: Int, i2: Int, i3: Int, i4: Int): Boolean
external fun SetForegroundWindow(hwnd: Long): Boolean
external fun SetFocus(hwnd: Long): Long
external fun IsWindowVisible(hwnd: Long): Boolean
external fun ShowWindow(hwnd: Long, i: Int): Boolean
external fun GetWindowThreadProcessId(hwnd: Long, intByReference: IntByReference?): Int
external fun AttachThreadInput(dword: Long, dword1: Long, b: Boolean): Boolean
external fun EnumWindows(enumProc: WndEnumProc): Boolean
external fun GetWindowTextA(hWnd: Pointer, lpString: ByteArray, nMaxCount: Int): Int

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,47 @@

package org.jire.overwatcheat.nativelib.interception

import com.sun.jna.Callback
import com.sun.jna.Pointer
import org.jire.overwatcheat.nativelib.DirectNativeLib
import java.lang.foreign.*

object Interception : DirectNativeLib("interception") {
object Interception {

@JvmStatic
external fun interception_is_keyboard(device: Int): Int
private val linker = Linker.nativeLinker()
private val interception = SymbolLookup.libraryLookup("interception", MemorySession.global())

@JvmStatic
external fun interception_is_mouse(device: Int): Int
private val interception_create_context = linker.downcallHandle(
interception.lookup("interception_create_context").get(),
FunctionDescriptor.of(ValueLayout.ADDRESS)
)

@JvmStatic
external fun interception_create_context(): Pointer
val interceptionContext = interception_create_context()

@JvmStatic
external fun interception_set_filter(context: Pointer, predicate: Callback, filter: Short)
private fun interception_create_context() = interception_create_context.invokeExact() as MemoryAddress

@JvmStatic
external fun interception_receive(context: Pointer, device: Int, stroke: InterceptionStroke, nstroke: Int): Int
val interceptionMouseStrokeLayout: GroupLayout = MemoryLayout.structLayout(
ValueLayout.JAVA_SHORT,
ValueLayout.JAVA_SHORT,
ValueLayout.JAVA_SHORT,
ValueLayout.JAVA_INT,
ValueLayout.JAVA_INT,
ValueLayout.JAVA_INT
)

@JvmStatic
external fun interception_wait(context: Pointer): Int
private fun interceptionSendSymbol() = interception.lookup("interception_send").get()

@JvmStatic
external fun interception_send(context: Pointer, device: Int, stroke: InterceptionStroke, nstroke: Int): Int
private val interception_send = linker.downcallHandle(
interceptionSendSymbol(),
FunctionDescriptor.of(
ValueLayout.JAVA_INT,
ValueLayout.ADDRESS, ValueLayout.JAVA_INT, interceptionMouseStrokeLayout, ValueLayout.JAVA_INT
)
)

@JvmStatic
external fun interception_destroy_context(context: Pointer)
fun interception_send(context: Addressable, device: Int, stroke: MemorySegment, strokeCount: Int) =
interception_send.invokeExact(
context,
device,
stroke,
strokeCount
) as Int

}
}

This file was deleted.

Loading

0 comments on commit 17a4709

Please sign in to comment.