Skip to content

Commit

Permalink
Added in-game UI toggling on shooting
Browse files Browse the repository at this point in the history
  • Loading branch information
Jire committed Dec 16, 2022
1 parent a5dcf05 commit d91b51b
Show file tree
Hide file tree
Showing 11 changed files with 127 additions and 49 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ The first step is to compile the source code into a usable cheat program.
* Double click on the "_build_" (_build.bat_) script and wait for it to complete

Once those steps are complete, the usable cheat program can be found within the _build_
directory, and will in a directory called **Overwatcheat 5.0.0**.
directory, and will in a directory called **Overwatcheat 5.1.0**.

From within the **Overwatcheat 5.0.0** directory, you can start the cheat by running the _"Start Overwatcheat 5.0.0"_
From within the **Overwatcheat 5.1.0** directory, you can start the cheat by running the _"Start Overwatcheat 5.1.0"_
script.

**Requirements:**
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group = "org.jire.overwatcheat"
version = "5.0.0"
version = "5.1.0"

kotlin {
jvmToolchain {
Expand Down
30 changes: 30 additions & 0 deletions src/main/kotlin/org/jire/overwatcheat/Keyboard.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
package org.jire.overwatcheat

import org.jire.overwatcheat.nativelib.User32Panama
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

object Keyboard {

Expand All @@ -28,4 +34,28 @@ object Keyboard {

fun keyReleased(virtualKeyCode: Int) = !keyPressed(virtualKeyCode)

val keyStroke =
MemorySegment.allocateNative(18, 4, MemorySession.global()).apply {
set(ValueLayout.JAVA_SHORT, 0, 0) // code
set(ValueLayout.JAVA_SHORT, 2, 0) // state
set(ValueLayout.JAVA_INT, 4, 0) // information
}

fun pressKey(key: Int, deviceId: Int) {
keyStroke.run {
set(ValueLayout.JAVA_SHORT, 0, key.toShort())
set(ValueLayout.JAVA_SHORT, 2, InterceptionKeyState.INTERCEPTION_KEY_DOWN.toShort())
}
interception_send(context, 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)
}

}

2 changes: 2 additions & 0 deletions src/main/kotlin/org/jire/overwatcheat/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ import org.jire.overwatcheat.aimbot.AimFrameHandler
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

object Main {

@JvmStatic
fun main(args: Array<String>) {
Kernel32.SetPriorityClass(Kernel32.GetCurrentProcess(), Kernel32.HIGH_PRIORITY_CLASS)
FFmpegLogCallback.set()

Settings.read()
Expand Down
26 changes: 10 additions & 16 deletions src/main/kotlin/org/jire/overwatcheat/Mouse.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,19 @@

package org.jire.overwatcheat

import org.jire.overwatcheat.nativelib.Kernel32
import org.jire.overwatcheat.nativelib.interception.InterceptionFilter
import org.jire.overwatcheat.nativelib.interception.InterceptionMouseFlag
import org.jire.overwatcheat.nativelib.interception.InterceptionPanama
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
import java.lang.foreign.ValueLayout

object Mouse {

private val context = InterceptionPanama.interception_create_context()

val stroke =
val mouseStroke =
MemorySegment.allocateNative(interceptionMouseStrokeLayout, MemorySession.global()).apply {
set(ValueLayout.JAVA_SHORT, 0, 0) // state
set(ValueLayout.JAVA_SHORT, 2, 0) // flags
Expand All @@ -47,27 +45,23 @@ object Mouse {
}

fun move(x: Int, y: Int, deviceID: Int) {
stroke.run {
mouseStroke.run {
set(ValueLayout.JAVA_INT, 8, x)
set(ValueLayout.JAVA_INT, 12, y)
}
InterceptionPanama.interception_send(context, deviceID, stroke, 1)
interception_send(context, deviceID, mouseStroke, 1)
}

fun click(deviceID: Int) {
stroke.run {
setAtIndex(ValueLayout.JAVA_INT, 0, InterceptionFilter.INTERCEPTION_MOUSE_LEFT_BUTTON_DOWN)
mouseStroke.run {
set(ValueLayout.JAVA_INT, 0, InterceptionFilter.INTERCEPTION_MOUSE_LEFT_BUTTON_DOWN)
set(ValueLayout.JAVA_INT, 8, 0)
set(ValueLayout.JAVA_INT, 12, 0)
}
InterceptionPanama.interception_send(context, deviceID, stroke, 1)
interception_send(context, deviceID, mouseStroke, 1)
sleep(300)
stroke.setAtIndex(ValueLayout.JAVA_INT, 0, InterceptionFilter.INTERCEPTION_MOUSE_LEFT_BUTTON_UP)
InterceptionPanama.interception_send(context, deviceID, stroke, 1)
}

init {
Kernel32.SetPriorityClass(Kernel32.GetCurrentProcess(), Kernel32.HIGH_PRIORITY_CLASS)
mouseStroke.set(ValueLayout.JAVA_INT, 0, InterceptionFilter.INTERCEPTION_MOUSE_LEFT_BUTTON_UP)
interception_send(context, deviceID, mouseStroke, 1)
}

}
14 changes: 13 additions & 1 deletion src/main/kotlin/org/jire/overwatcheat/aimbot/AimBotThread.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@ class AimBotThread(
priority = MAX_PRIORITY

val tlr = ThreadLocalRandom.current()
var wasPressed = false
while (true) {
val elapsed = measureNanoTime {
if (!Keyboard.keyPressed(Settings.aimKey)) {
val pressed = Keyboard.keyPressed(Settings.aimKey)
if (Settings.toggleInGameUI && wasPressed != pressed) toggleUI(1)
wasPressed = pressed
if (!pressed) {
AimBotState.aimData = 0
return@measureNanoTime
} else if (Settings.aimMode == 1) {
Expand Down Expand Up @@ -118,4 +122,12 @@ class AimBotThread(
}
}

private fun toggleUI(deviceId: Int) {
Keyboard.pressKey(56, deviceId)
Keyboard.pressKey(44, deviceId)

Keyboard.releaseKey(44, deviceId)
Keyboard.releaseKey(56, deviceId)
}

}
52 changes: 27 additions & 25 deletions src/main/kotlin/org/jire/overwatcheat/aimbot/AimFrameHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,36 @@ class AimFrameHandler(val colorMatcher: AimColorMatcher) : FrameHandler {
override fun handle(frame: Frame) {
val frameWidth = frame.imageWidth
val frameHeight = frame.imageHeight
val data = frame.image[0] as ByteBuffer
for (image in frame.image) {
val data = image as ByteBuffer

var found = false
var xHigh = Int.MIN_VALUE
var xLow = Int.MAX_VALUE
var yHigh = Int.MIN_VALUE
var yLow = Int.MAX_VALUE
for (x in 0..frameWidth - 1) {
for (y in 0..frameHeight - 1) {
val dataIndexBase = frameWidth * y * 3
val dataIndex = dataIndexBase + (x * 3)
if (!colorMatches(data, dataIndex)) continue
var found = false
var xHigh = Int.MIN_VALUE
var xLow = Int.MAX_VALUE
var yHigh = Int.MIN_VALUE
var yLow = Int.MAX_VALUE
for (x in 0..frameWidth - 1) {
for (y in 0..frameHeight - 1) {
val dataIndexBase = frameWidth * y * 3
val dataIndex = dataIndexBase + (x * 3)
if (!colorMatches(data, dataIndex)) continue

found = true
if (x > xHigh) xHigh = x
if (x < xLow) xLow = x
if (y > yHigh) yHigh = y
if (y < yLow) yLow = y
found = true
if (x > xHigh) xHigh = x
if (x < xLow) xLow = x
if (y > yHigh) yHigh = y
if (y < yLow) yLow = y
}
}
}

AimBotState.aimData =
if (found)
(xLow.toLong() shl 48) or
(xHigh.toLong() shl 32) or
(yLow.toLong() shl 16) or
yHigh.toLong()
else 0
AimBotState.aimData =
if (found)
(xLow.toLong() shl 48) or
(xHigh.toLong() shl 32) or
(yLow.toLong() shl 16) or
yHigh.toLong()
else 0
}
}

private fun pixelRGB(data: ByteBuffer, dataIndex: Int): Int {
Expand All @@ -66,4 +68,4 @@ class AimFrameHandler(val colorMatcher: AimColorMatcher) : FrameHandler {

private fun colorMatches(data: ByteBuffer, dataIndex: Int) = colorMatcher.colorMatches(pixelRGB(data, dataIndex))

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class FrameGrabber(

setOption("draw_mouse", "0")
setOption("show_region", "0")

setOption("tune", "zerolatency")
}

private companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Free, open-source undetected color cheat for Overwatch!
* Copyright (C) 2017 Thomas G. Nappo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package org.jire.overwatcheat.nativelib.interception

object InterceptionKeyState {

const val INTERCEPTION_KEY_DOWN = 0x00
const val INTERCEPTION_KEY_UP = 0x01
const val INTERCEPTION_KEY_E0 = 0x02
const val INTERCEPTION_KEY_E1 = 0x04
const val INTERCEPTION_KEY_TERMSRV_SET_LED = 0x08
const val INTERCEPTION_KEY_TERMSRV_SHADOW = 0x10
const val INTERCEPTION_KEY_TERMSRV_VKPACKET = 0x20

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ object InterceptionPanama {
FunctionDescriptor.of(ValueLayout.ADDRESS)
)

val context = interception_create_context()

fun interception_create_context() = interception_create_context.invokeExact() as MemoryAddress

val interceptionMouseStrokeLayout: GroupLayout = MemoryLayout.structLayout(
Expand All @@ -41,20 +43,22 @@ object InterceptionPanama {
ValueLayout.JAVA_INT
)

private fun interceptionSendSymbol() = interception.lookup("interception_send").get()

private val interception_send = linker.downcallHandle(
interception.lookup("interception_send").get(),
interceptionSendSymbol(),
FunctionDescriptor.of(
ValueLayout.JAVA_INT,
ValueLayout.ADDRESS, ValueLayout.JAVA_INT, interceptionMouseStrokeLayout, ValueLayout.JAVA_INT
)
)

fun interception_send(context: Addressable, device: Int, stroke: MemorySegment, nstroke: Int) =
fun interception_send(context: Addressable, device: Int, stroke: MemorySegment, strokeCount: Int) =
interception_send.invokeExact(
context,
device,
stroke,
nstroke
strokeCount
) as Int

}
3 changes: 2 additions & 1 deletion src/main/kotlin/org/jire/overwatcheat/settings/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ object Settings {
val aimOffsetX by FloatSetting("aim_offset_x", 1.00F)
val aimOffsetY by FloatSetting("aim_offset_y", 0.75F)
val enableOverlay by BooleanSetting("enable_overlay", false)
val toggleInGameUI by BooleanSetting("toggle_in_game_ui", true)

const val DEFAULT_FILE = "overwatcheat.cfg"

Expand All @@ -65,4 +66,4 @@ object Settings {
}
}

}
}

0 comments on commit d91b51b

Please sign in to comment.