Skip to content

Instantly share code, notes, and snippets.

View NaniteFactory's full-sized avatar
😊
Hi

NaniteFactory

😊
Hi
View GitHub Profile
@NaniteFactory
NaniteFactory / setcookie.go
Created October 21, 2019 06:30
chromedp set-cookie example
package main
import (
"context"
"fmt"
"log"
"time"
"github.com/chromedp/cdproto/cdp"
"github.com/chromedp/cdproto/network"
@NaniteFactory
NaniteFactory / ComponentList.SC2Components
Last active October 5, 2019 10:11
12 keys of MPQ ComponentList.SC2Components
<?xml version="1.0" encoding="us-ascii"?>
<Components>
<DataComponent Type="gada">GameData</DataComponent>
<DataComponent Type="text" Locale="enUS">GameText</DataComponent>
<DataComponent Type="info">DocumentInfo</DataComponent>
<DataComponent Type="mapi">MapInfo</DataComponent>
<DataComponent Type="trig">Triggers</DataComponent>
<DataComponent Type="terr">t3Terrain.xml</DataComponent>
<DataComponent Type="plob">Objects</DataComponent>
<DataComponent Type="attr">Attributes</DataComponent>
@NaniteFactory
NaniteFactory / explode_multiple_returns.go
Last active January 31, 2019 07:50
Exploding multiple returns to pass to a call to a variadic function.
package main
func multipleRets() (int, int, int, int) {
return 11, 22, 33, 44
}
func main() {
s1 := append([]int{}, []int{11, 22, 33, 44}...) // This is fine.
s2 := append([]int{}, multipleRets()) // But this one errors.
s3 := append([]int{}, toSlice(multipleRets())...) // Getting through it.
@NaniteFactory
NaniteFactory / sum.go
Created January 25, 2019 17:19
a Golang function that takes multiple numbers as its parameter then returns the sum of those
sum := func(nums ...float64) float64 {
ret := 0.0
for _, num := range nums {
ret += num
}
return ret
}
@NaniteFactory
NaniteFactory / test_write_to_memory.go
Last active May 31, 2022 03:10
golang runtime bytes patch in windows
package main
import (
"unsafe"
"github.com/nanitefactory/memory"
"github.com/nanitefactory/outputdbg"
)
// #include <windows.h>
@NaniteFactory
NaniteFactory / manifest.json
Created December 19, 2018 09:46
chrome theme
{
"manifest_version": 2,
"name": "Orange frame with distinguishable gray tabs",
"version": "0.1",
"theme": {
"colors": {
"background_tab": [ 210, 213, 217 ],
"background_tab_inactive": [ 213, 215, 220 ],
"background_tab_incognito": [ 38, 39, 42 ],
"background_tab_incognito_inactive": [ 53, 56, 58 ],
@NaniteFactory
NaniteFactory / imageToColors.go
Created December 13, 2018 06:37
Get a single dimensional color.Color list (array) from an image.Image and vice versa.
func imageToColors(img image.Image) []color.Color {
rect := img.Bounds()
width := rect.Dx()
height := rect.Dy()
xFrom := rect.Min.X
xTo := rect.Max.X
yFrom := rect.Max.Y - 1
yTo := rect.Min.Y - 1
ret := make([]color.Color, width*height)
@NaniteFactory
NaniteFactory / c_function_hook_x64.go
Last active May 12, 2022 20:09
API hook in Golang.
package main
import (
"log"
"syscall"
"unsafe"
"github.com/nanitefactory/gominhook" // In order to use this package you need to have MinHook.x64.dll in your system.
)
@NaniteFactory
NaniteFactory / invalid_address.go
Created October 20, 2018 15:27
Suggesting ways to handle invalid addresses in Golang.
package main
import (
"errors"
"log"
"unsafe"
)
func foo1() (err error) {
defer func() {
@NaniteFactory
NaniteFactory / lpcwstr.go
Last active September 21, 2023 00:12 — forked from icholy/lpcwstr.go
Convert the UTF16 Wide String (WSTR) from/to plain Go string.
package lpcwstr
// #include <windows.h>
// #include <wchar.h>
// #include <WinNT.h>
import "C"
import (
"unicode/utf16"
"unsafe"