Skip to content

Instantly share code, notes, and snippets.

// gcc -o overwirte_iat.exe overwwrite_iat1.c -lDbghelp
#include <windows.h>
#include <stdio.h>
#include <inttypes.h>
#include <dbghelp.h>
FILE *myfopen(const char *fname, const char *mode)
{
return stdout;
local ffi = require'ffi'
ffi.cdef[[
typedef unsigned long DWORD;
typedef void* HANDLE;
typedef int BOOL;
BOOL GetConsoleMode(HANDLE h, DWORD *mode);
BOOL SetConsoleMode(HANDLE h, DWORD mode);
HANDLE GetStdHandle(DWORD stdhandle);
enum {
STD_INPUT_HANDLE = ((DWORD)-10),
@erw7
erw7 / forecast.txt
Last active March 28, 2022 03:19
nvim resize problem
sigwinch_cb (1)
sigwinch_cb (2)
sigwinch_cb (3)
tui_grid_resize (1) -> got_winch = false
tui_grid_resize (2) -> uinibi_out_ext(ui, data->unibi_ext.resize_screen)
sigwinch_cb (4) -> got_winch = true by tui_grid_resize (2)
tui_grid_resize (3) -> got_winch = false
tui_grid_resize (4) -> uinibi_out_ext(ui, data->unibi_ext.resize_screen)
sigwinch_cb (5) -> got_winch = true by tui_grid_resize (4)
tui_grid_resize (5) -> got_winch = false
http://invisible-island.net/xterm/
XTerm Control Sequences
Edward Moy
University of California, Berkeley
Revised by
Copyright 2005 Red Hat Inc., Max Kaehn
All cygwin threads have separate context in an object of class _cygtls. The
storage for this object is kept on the stack in the bottom CYGTLS_PADSIZE
bytes. Each thread references the storage via the Thread Environment Block
(aka Thread Information Block), which Windows maintains for each user thread
in the system, with the address in the FS segment register. The memory
is laid out as in the NT_TIB structure from <w32api/winnt.h>:
全ての cygwin スレッドは class _cygtls のオブジェクト中に別個のコンテキストを持っています。
@erw7
erw7 / ping_pong.lua
Last active September 11, 2021 15:23
Testing the use of threads from Lua in Neovim
-- When running on a thread from luajit on Windows, it terminates abnormally
-- with "Uncaught Error: attempt to call nil value" after calling on_setup().
-- If executed in the main thread, session:run() will return without blocking.
local uv = vim and vim.loop or require'luv'
local M = {}
local id = 0
function M.entry_func(id, file_or_addr, is_remote)
state_enter
terminal_execute
terminal_send_key
vterm_keyboard_key
or
vterm_keyboard_unichar
terminal_fluash_output
vterm_output_read
terminal_send
term->opt.write_cb = term_write (Set by channel_terminal_open called from f_termopen)
@erw7
erw7 / _overlapped.py.2.diff
Last active August 16, 2021 08:56
Fixed a bug in _overlapped.py in pypy3
--- _overlapped.py.orig 2021-08-16 13:38:30.403944500 +0900
+++ _overlapped.py 2021-08-16 17:53:21.577925100 +0900
@@ -272,17 +272,17 @@
if self.type != OverlappedType.TYPE_NONE:
_winapi.raise_WinError()
- self.write_buffer = bytes(bufobj)
+ self.write_buffer = _ffi.new("WSABUF[1]")
self.type = OverlappedType.TYPE_WRITE
self.handle = handle
--[[
Use Windows native clangd from wsl neovim.
git clone https://github.com/neovim/nvim-lspconfig ~/src/github.com/neovim/nvim-lspconfig
nvim -u init.lua
]]--
vim.o.rtp = '~/src/github.com/neovim/nvim-lspconfig,' .. vim.o.rtp
local URI_SCHEME_PATTERN = '^([a-zA-Z]+[a-zA-Z0-9+-.]*)://.*'
@erw7
erw7 / dein.toml
Last active January 23, 2021 06:46
Lazy loading with on_lua in dein
[ftplugin]
c = '''
if !exists('s:loaded')
" We only need to call 'setup' the first time. If neovim/nvim-lspconfig#676
" is not merged, multiple calls to 'setup' will result in multiple autocmd
" settings, multiple 'try_add' runs, and multiple client runs for nothing.
lua require'lspconfig'.clangd.setup{}
" After calling setup, autocmd will call 'try_add', so call 'try_add' only the
" first time.
lua require'lspconfig'['clangd'].manager.try_add()