Skip to content

Commit

Permalink
Rename folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Zusier committed Dec 4, 2021
1 parent 34d00d6 commit 661b686
Show file tree
Hide file tree
Showing 10 changed files with 189 additions and 189 deletions.
30 changes: 15 additions & 15 deletions gamemode/.gitignore → gameutil/.gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/
162 changes: 81 additions & 81 deletions gamemode/WindowsProcess.go → gameutil/WindowsProcess.go
Original file line number Diff line number Diff line change
@@ -1,81 +1,81 @@
// authored by @spddl, thank you!
package main

import (
"strconv"
"strings"
"syscall"
"unsafe"

"golang.org/x/sys/windows"
)

const TH32CS_SNAPPROCESS = 0x00000002

type Processes struct {
Processes []Process
}

type Process struct {
ProcessID int
ParentProcessID int
Exe string
}

func (wp *Processes) getProcesses() error {
handle, err := windows.CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
if err != nil {
return err
}
defer windows.CloseHandle(handle)

var entry windows.ProcessEntry32
entry.Size = uint32(unsafe.Sizeof(entry))

// get the first process
err = windows.Process32First(handle, &entry)
if err != nil {
return err
}

for {
wp.Processes = append(wp.Processes, newWindowsProcess(&entry))

err = windows.Process32Next(handle, &entry)
if err != nil {
// windows sends ERROR_NO_MORE_FILES on last process
if err == syscall.ERROR_NO_MORE_FILES {
return nil
}
return err
}
}
}

func (wp Processes) findProcessIDByNames(names []string) []string {
var result []string
for _, p := range wp.Processes {
for _, name := range names {
if strings.EqualFold(p.Exe, name) {
result = append(result, strconv.Itoa(p.ProcessID))
}
}

}
return result
}
func newWindowsProcess(e *windows.ProcessEntry32) Process {
// Find when the string ends for decoding
end := 0
for {
if e.ExeFile[end] == 0 {
break
}
end++
}
return Process{
ProcessID: int(e.ProcessID),
ParentProcessID: int(e.ParentProcessID),
Exe: syscall.UTF16ToString(e.ExeFile[:end]),
}
}
// authored by @spddl, thank you!
package main

import (
"strconv"
"strings"
"syscall"
"unsafe"

"golang.org/x/sys/windows"
)

const TH32CS_SNAPPROCESS = 0x00000002

type Processes struct {
Processes []Process
}

type Process struct {
ProcessID int
ParentProcessID int
Exe string
}

func (wp *Processes) getProcesses() error {
handle, err := windows.CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
if err != nil {
return err
}
defer windows.CloseHandle(handle)

var entry windows.ProcessEntry32
entry.Size = uint32(unsafe.Sizeof(entry))

// get the first process
err = windows.Process32First(handle, &entry)
if err != nil {
return err
}

for {
wp.Processes = append(wp.Processes, newWindowsProcess(&entry))

err = windows.Process32Next(handle, &entry)
if err != nil {
// windows sends ERROR_NO_MORE_FILES on last process
if err == syscall.ERROR_NO_MORE_FILES {
return nil
}
return err
}
}
}

func (wp Processes) findProcessIDByNames(names []string) []string {
var result []string
for _, p := range wp.Processes {
for _, name := range names {
if strings.EqualFold(p.Exe, name) {
result = append(result, strconv.Itoa(p.ProcessID))
}
}

}
return result
}
func newWindowsProcess(e *windows.ProcessEntry32) Process {
// Find when the string ends for decoding
end := 0
for {
if e.ExeFile[end] == 0 {
break
}
end++
}
return Process{
ProcessID: int(e.ProcessID),
ParentProcessID: int(e.ParentProcessID),
Exe: syscall.UTF16ToString(e.ExeFile[:end]),
}
}
File renamed without changes.
60 changes: 30 additions & 30 deletions gamemode/config.go → gameutil/config.go
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
package main

import (
"encoding/json"
"fmt"
"io/ioutil"
)

// config
type config struct {
TIMERRES int16
KILL_DWM bool
KILL_EXPLORER bool
DISABLE_IDLE bool
}

func GetConfig(params ...string) config {
file, err := ioutil.ReadFile("config.json")
if err != nil {
fmt.Println("Error ReadFile:", err)
}

var data = config{}
err = json.Unmarshal(file, &data)
if err != nil {
fmt.Println("Error Unmarshal:", err)
}

return data
}
package main

import (
"encoding/json"
"fmt"
"io/ioutil"
)

// config
type config struct {
TIMERRES int16
KILL_DWM bool
KILL_EXPLORER bool
DISABLE_IDLE bool
}

func GetConfig(params ...string) config {
file, err := ioutil.ReadFile("config.json")
if err != nil {
fmt.Println("Error ReadFile:", err)
}

var data = config{}
err = json.Unmarshal(file, &data)
if err != nil {
fmt.Println("Error Unmarshal:", err)
}

return data
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
nsudo -U:T -P:E -CurrentDirectory:%~dp0 gameutil.exe
nsudo -U:T -P:E -CurrentDirectory:%~dp0 gameutil.exe
pause
File renamed without changes.
124 changes: 62 additions & 62 deletions gamemode/win32api.go → gameutil/win32api.go
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
// coauthored by @spddl, thank you!
package main

import (
"syscall"

"golang.org/x/sys/windows"
)

// Breaks when calling from main.go, just replaced with 0x1F0FFF
// const PROCESS_ALL_ACCESS = 0x1F0FF

var (
// Library
ntdllDLL = windows.NewLazySystemDLL("ntdll.dll")

// Functions
procNtSuspendProcess = ntdllDLL.NewProc("NtSuspendProcess")
procNtResumeProcess = ntdllDLL.NewProc("NtResumeProcess")
// procNtQueryTimerResolution = ntdllDLL.NewProc("NtQueryTimerResolution")
procNtSetTimerResolution = ntdllDLL.NewProc("NtSetTimerResolution")
)

func SuspendProc(pid uint32) {
handle, err := windows.OpenProcess(0x1F0FFF, false, pid)
if err != nil {
panic(err)
}
procNtSuspendProcess.Call(uintptr(handle))
}

func NtResumeProcess(pid uint32) {
handle, err := windows.OpenProcess(0x1F0FFF, false, pid)
if err != nil {
panic(err)
}
procNtResumeProcess.Call(uintptr(handle))
}

/*
// https://www.pinvoke.net/default.aspx/ntdll.NtQueryTimerResolution
// http://undocumented.ntinternals.net/index.html?page=UserMode%2FUndocumented%20Functions%2FTime%2FNtQueryTimerResolution.html
func NtQueryTimerResolution(maximumResolution, minimumResolution, currentResolution *uint64) bool {
ret, _, _ := syscall.Syscall(procNtQueryTimerResolution.Addr(), 3,
uintptr(unsafe.Pointer(maximumResolution)),
uintptr(unsafe.Pointer(minimumResolution)),
uintptr(unsafe.Pointer(&currentResolution)),
)
return ret != 0
}
*/

func NtSetTimerRes(res int16) (currentResolution uint64) {
syscall.Syscall(procNtSetTimerResolution.Addr(), 3,
uintptr(res),
uintptr(1),
// Believe this isn't required, and adds extra module.
// uintptr(unsafe.Pointer(&currentResolution)),
0,
)
return
}
// coauthored by @spddl, thank you!
package main

import (
"syscall"

"golang.org/x/sys/windows"
)

// Breaks when calling from main.go, just replaced with 0x1F0FFF
// const PROCESS_ALL_ACCESS = 0x1F0FF

var (
// Library
ntdllDLL = windows.NewLazySystemDLL("ntdll.dll")

// Functions
procNtSuspendProcess = ntdllDLL.NewProc("NtSuspendProcess")
procNtResumeProcess = ntdllDLL.NewProc("NtResumeProcess")
// procNtQueryTimerResolution = ntdllDLL.NewProc("NtQueryTimerResolution")
procNtSetTimerResolution = ntdllDLL.NewProc("NtSetTimerResolution")
)

func SuspendProc(pid uint32) {
handle, err := windows.OpenProcess(0x1F0FFF, false, pid)
if err != nil {
panic(err)
}
procNtSuspendProcess.Call(uintptr(handle))
}

func NtResumeProcess(pid uint32) {
handle, err := windows.OpenProcess(0x1F0FFF, false, pid)
if err != nil {
panic(err)
}
procNtResumeProcess.Call(uintptr(handle))
}

/*
// https://www.pinvoke.net/default.aspx/ntdll.NtQueryTimerResolution
// http://undocumented.ntinternals.net/index.html?page=UserMode%2FUndocumented%20Functions%2FTime%2FNtQueryTimerResolution.html
func NtQueryTimerResolution(maximumResolution, minimumResolution, currentResolution *uint64) bool {
ret, _, _ := syscall.Syscall(procNtQueryTimerResolution.Addr(), 3,
uintptr(unsafe.Pointer(maximumResolution)),
uintptr(unsafe.Pointer(minimumResolution)),
uintptr(unsafe.Pointer(&currentResolution)),
)
return ret != 0
}
*/

func NtSetTimerRes(res int16) (currentResolution uint64) {
syscall.Syscall(procNtSetTimerResolution.Addr(), 3,
uintptr(res),
uintptr(1),
// Believe this isn't required, and adds extra module.
// uintptr(unsafe.Pointer(&currentResolution)),
0,
)
return
}

0 comments on commit 661b686

Please sign in to comment.