Skip to content

Instantly share code, notes, and snippets.

@wyyqyl
wyyqyl / GetTcpTable2.cpp
Created April 9, 2014 03:38
Print network connection state
#include <winsock2.h>
#include <ws2tcpip.h>
#include <iphlpapi.h>
#include <stdio.h>
// Need to link with Iphlpapi.lib and Ws2_32.lib
#pragma comment(lib, "iphlpapi.lib")
#pragma comment(lib, "ws2_32.lib")
#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
@wyyqyl
wyyqyl / MsgThread.cpp
Created April 10, 2014 07:59
Integrate boost::thread with Windows MSG
#include <windows.h>
#include <boost/thread/thread.hpp>
LRESULT MsgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
LRESULT result = 0;
switch (message) {
case WM_TIMER:
std::cout << "WM_TIMER" << std::endl;
result = 1;
break;
@wyyqyl
wyyqyl / SimpleWinMain.cpp
Created April 16, 2014 06:38
simple winmain application
// bsm.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "bsm.h"
HINSTANCE hInst;
TCHAR szTitle[] = TEXT("");
TCHAR szWindowClass[] = TEXT(" ");
@wyyqyl
wyyqyl / download_crx.go
Created April 29, 2014 13:24
Download .crx file from web server, and don't let chrome display yellow bar at the top of the page
package main
import (
"log"
"net/http"
"os"
"strconv"
)
func handler(w http.ResponseWriter, r *http.Request) {
@wyyqyl
wyyqyl / 0_reuse_code.js
Created June 13, 2014 15:44
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@wyyqyl
wyyqyl / cpplint.py
Last active August 29, 2015 14:02
This is automated checker to make sure a C++ file follows Google's C++ style guide (http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml).
#!/usr/bin/python
#
# Copyright (c) 2009 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
@wyyqyl
wyyqyl / run_process.cpp
Created July 18, 2014 06:15
run_process
void run_process(const wchar_t* name, const wchar_t* param) {
SHELLEXECUTEINFOW info;
info.cbSize = sizeof(SHELLEXECUTEINFOW);
info.fMask = SEE_MASK_NOCLOSEPROCESS;
info.hwnd = NULL;
info.lpVerb = NULL;
info.lpFile = name;
info.lpParameters = param;
info.lpDirectory = NULL;
info.nShow = SW_HIDE;
@wyyqyl
wyyqyl / port.py
Created October 28, 2014 01:42
port occupation demo
import socket
HOST = '127.0.0.1'
try:
s1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s1.bind((HOST, 13748))
s2 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s2.bind((HOST, 15428))
@wyyqyl
wyyqyl / icmp.go
Last active August 29, 2015 14:09
ping request
package main
import (
"bytes"
"encoding/binary"
"fmt"
"net"
"time"
)
@wyyqyl
wyyqyl / 189cm.go
Created November 21, 2014 12:36
send packets to server to emulate user operation
package main
import (
"bytes"
"compress/gzip"
"fmt"
"io"
"math/rand"
"net/http"
"net/url"