Skip to content

Instantly share code, notes, and snippets.

@lxfly2000
lxfly2000 / officevl.js
Last active March 28, 2018 11:39
Office 2016 激活脚本(注意保存为GBK编码)
//该脚本用于激活 Office 2016.
//This script is written for activating Office 2016.
//如果有Bug或者任何疑问请邮件联系 [email protected] 或微博 lxfly2000.
//Any bugs or questions please contact me at [email protected] or lxfly2000 on Weibo.
//使用方法:在管理员模式下执行命令行“officevl <KMS服务器>”
//Usage: Run this command with Administrator "officevl <KMS Server>"
var sn="XQNVK-8JYDB-WJ9W3-YJ8YR-WFG99";//激活序列号,可到 https://technet.microsoft.com/zh-cn/library/dn385360(v=office.16).aspx 上找。
var kmsserver="";//在此处填入KMS服务器地址
if(WScript.Arguments.length>0)
@lxfly2000
lxfly2000 / cvdiff.cpp
Created January 27, 2018 05:50
比较两个图像是否相似或一致。(https://pan.baidu.com/s/1htqQ5pi
//采用OpenCV轮廓匹配判断两个简单图片是否相似或一致
#include <iostream>
#include <opencv/cv.hpp>
//测试图片B是否与图片A相似,越接近0表示越相似,反之不相似
//IplImage到Mat转换:http://blog.sina.com.cn/s/blog_534497fd01015k7z.html
//参考:http://blog.csdn.net/qq_18343569/article/details/48004201
//参考:http://blog.csdn.net/qq_15947787/article/details/72773893
double TestDifference(const IplImage *imgA, const IplImage *imgB, int method = CV_CONTOURS_MATCH_I1,
double thresholdA1 = 50, double thresholdA2 = 60, double thresholdB1 = 50, double thresholdB2 = 60)
//手动解析32位浮点数(1位符号+8位阶码(指数)+23位尾数)
#define BITS_SIGN 1
#define BITS_EXP 8
#define BITS_TAIL 23
#include<stdio.h>
#include<string.h>
#include<math.h>
#define GetBit(n,bit) (((n)>>(BITS_SIGN+BITS_EXP+BITS_TAIL-1-(bit)))&1)
@lxfly2000
lxfly2000 / readmem.cpp
Created November 3, 2017 09:12
任意进程的内存读取/修改
#include<iostream>
#include<string>
#include<Windows.h>
#include<TlHelp32.h>
DWORD QueryFirstPIDOfProcessName(LPCWSTR pn)
{
PROCESSENTRY32 pe;
pe.dwSize = sizeof pe;
HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
for (BOOL notend = Process32First(hProcessSnap, &pe); notend; notend = Process32Next(hProcessSnap, &pe))
@lxfly2000
lxfly2000 / Extract.cpp
Created October 7, 2017 05:13
使用Windows自带的API解压zip文件。
#include<Windows.h>
#include<ShObjIdl.h>
#include<ShlObj.h>
#include<fstream>
LPWSTR TrimQuote(LPWSTR str)
{
int ifrom = 0, ito = 0;
while (str[ifrom])
{
if (str[ifrom] != '\"')
@lxfly2000
lxfly2000 / pixiv-hosts.txt
Created September 19, 2017 11:55
Hosts for pixiv and its services.
#Pixiv Start
210.129.120.44 pixiv.net
210.129.120.43 pixiv.net
210.129.120.41 pixiv.net
210.129.120.44 www.pixiv.net
210.129.120.43 www.pixiv.net
210.129.120.41 www.pixiv.net
210.140.131.144 source.pixiv.net
210.140.131.147 source.pixiv.net
210.140.131.145 source.pixiv.net
@lxfly2000
lxfly2000 / rmitomid.c
Last active September 8, 2017 14:21
RMI与MIDI文件相互转换程序。
//参考:http://www.yueshou.net/jiao/shuma/yingjian/200608/14735.html
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define stricmp _stricmp
struct RMIDHeader
{
char strRIFF[4];
int chunkSize;
char strFormat[4];
@lxfly2000
lxfly2000 / wavsplit.cpp
Last active September 6, 2017 09:47
音频分隔
#include<iostream>
#include<fstream>
#include<string>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(x) ((x)>0?(x):-(x))
typedef short DataStructure_16BitMono;
struct WaveStructure
{
char strRIFF[4];
@lxfly2000
lxfly2000 / luainter.c
Last active September 10, 2017 03:05
Lua与C语言函数相互调用示例。
//Lua与C交互示例,参考:http://blog.csdn.net/shun_fzll/article/details/39120965
#include<stdio.h>
#include<string.h>
#include"lua.h"
#include"lualib.h"
#include"lauxlib.h"
#pragma comment(lib,"lua53.lib")
#define C(action,r) if(r=action)return r
#define LVAR_NAME "luanum"
const char luasource[] =
@lxfly2000
lxfly2000 / HookSrc.cpp
Created July 12, 2017 13:08
替换函数地址实现Hook。
//参考:http://blog.csdn.net/friendan/article/details/12222651
//目前只能对自身进程Hook。
#ifndef WIN32
#error 该程序目前只能在 x86 平台中使用。
#endif
#include<Windows.h>
using FUNCTYPE = decltype(MessageBox);
FUNCTYPE *funcOriginal = nullptr;
DWORD protectOriginal;
bool hookOn = false;