Skip to content

Instantly share code, notes, and snippets.

View NaniteFactory's full-sized avatar
😊
Hi

NaniteFactory

😊
Hi
View GitHub Profile
@NaniteFactory
NaniteFactory / messagebox.go
Last active April 24, 2024 17:58
Win32 API MessageBox() in Golang
import (
"syscall"
"unsafe"
)
// MessageBox of Win32 API.
func MessageBox(hwnd uintptr, caption, title string, flags uint) int {
ret, _, _ := syscall.NewLazyDLL("user32.dll").NewProc("MessageBoxW").Call(
uintptr(hwnd),
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(caption))),
@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 / dllmain.go
Last active March 15, 2024 16:35
An implementation example of DllMain() entrypoint with Golang. $ go build --buildmode=c-shared -o my.dll && rundll32.exe my.dll Test
package main
//#include "dllmain.h"
import "C"
@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"
@NaniteFactory
NaniteFactory / skin_fixed.html
Last active August 21, 2023 06:10
티스토리 로그인 로그아웃
<li class="tab_login"><a href="#" id="tab_login_toggle" onclick="fnLoginToggle();"></a>
<script>
function fnLoginToggle() {};
$(function() {
if(window.T.config.USER.name) {
$('#tab_login_toggle').text('로그아웃');
fnLoginToggle = function() { document.location.href = "https://www.tistory.com/auth/logout?redirectUrl=" + encodeURIComponent(window.location.href); };
} else {
$('#tab_login_toggle').text('로그인');
fnLoginToggle = function() { document.location.href = "https://www.tistory.com/auth/login?redirectUrl=" + encodeURIComponent(window.location.href); };
@NaniteFactory
NaniteFactory / shard.go
Created June 8, 2020 03:37
Discordgo sharding
package shard
import (
"errors"
"fmt"
"strconv"
"sync"
"github.com/bwmarrin/discordgo"
)
@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 / 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 / traverse_unmarshalled_json.go
Created August 5, 2018 09:18
Traverse / iterate over an unmarshalled JSON data in Golang.
package main
import (
"encoding/json"
"errors"
"fmt"
"io"
"os"
)

pprof 사용법

1. pprof의 구분

  1. go tool pprof 프로그램:
    • pprof 데이터를 분석하여 보여 주는 pprof 바이너리다.
  2. runtime/pprof 패키지:
    • Go 프로그램으로부터 pprof 데이터를 생성하여 내보내는 일을 하는 패키지다.
  3. net/http/pprof 패키지:
    • runtime/pprof 패키지가 하고 있는 것을 (ServeHTTP로) 웹으로 내보내거나 프로그램의 pprof 데이터를 분석하여 웹 인터페이스로 보여 주는 일을 하는 패키지다.