Skip to content

Instantly share code, notes, and snippets.

@Temptationx
Temptationx / UTF-8与GBK(或GB2312)编码转换.cpp
Created December 6, 2017 00:13
UTF-8与GBK(或GB2312)编码转换
string GBKToUTF8(const char* strGBK)
{
int len = MultiByteToWideChar(CP_ACP, 0, strGBK, -1, NULL, 0);
wchar_t* wstr = new wchar_t[len+1];
memset(wstr, 0, len+1);
MultiByteToWideChar(CP_ACP, 0, strGBK, -1, wstr, len);
len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL);
char* str = new char[len+1];
memset(str, 0, len+1);
WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, len, NULL, NULL);
@Temptationx
Temptationx / disconnect.c++
Last active March 14, 2019 19:20
C++ lambda Qt disconnect
auto conn = std::make_shared<QMetaObject::Connection>();
*conn = QObject::connect(obj, &Object::signal, this, [this, conn]() {
disconnect(*conn);
});
@Temptationx
Temptationx / 6 omxplayer
Created February 16, 2018 06:13
6 omxplayer
nohup omxplayer --win 0,0,640,480 -n -1 SampleVideo_640x360_30mb.mp4 &
nohup omxplayer --win 640,0,1280,480 -n -1 SampleVideo_640x360_30mb.mp4 &
nohup omxplayer --win 1280,0,1920,480 -n -1 SampleVideo_640x360_30mb.mp4 &
nohup omxplayer --win 0,480,640,960 -n -1 SampleVideo_640x360_30mb.mp4 &
nohup omxplayer --win 640,480,1280,960 -n -1 SampleVideo_640x360_30mb.mp4 &
@Temptationx
Temptationx / gist:0e107e446918cc7f3ed9bb221c32dc02
Created December 2, 2017 12:54
wstring与string相互转换
#include <string>
#include <locale.h>
// 需包含locale、string头文件、使用setlocale函数。
std::wstring StringToWstring(const std::string str)
{// string转wstring
unsigned len = str.size() * 2;// 预留字节数
setlocale(LC_CTYPE, ""); //必须调用此函数
wchar_t *p = new wchar_t[len];// 申请一段内存存放转换后的字符串
mbstowcs(p,str.c_str(),len);// 转换
std::string s(std::istreambuf_iterator<char>(Poco::FileInputStream(string("t.txt"))), {});
@Temptationx
Temptationx / 1080p
Created November 25, 2017 06:49
ubuntu强制分辨率
#!/bin/bash
xrandr --newmode "1920x1080_60_001" 172.80 1920 2040 2248 2576 1080 1081 1084 1118 -HSync +Vsync
xrandr --addmode VGA-1 "1920x1080_60_001"
xrandr --output VGA-1 --mode "1920x1080_60_001"
extern GetStdHandle
extern WriteConsoleA
extern ExitProcess
[SECTION .data]
align 32
_dummy:
dd 0
_message:
db 'Hello, world!', 0dh, 0ah
#include <Windows.h>
#include <stdio.h>
#include "dbghelp.h"
BOOL WINAPI InitSymHandler( )
{
BOOL bReturn = FALSE;
HANDLE hFile;
CHAR DirPath[MAX_PATH] = {0};
#include "stdafx.h"
#include <Windows.h>
#include <imagehlp.h>
#include <locale.h>
#pragma comment(lib,"DbgHelp.lib")
BOOL CALLBACK CallBackProc( PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID UserContext )
{
printf( "函数名: %s\r\n地址: %08X \r\n\r\n", pSymInfo->Name, pSymInfo->Address );
return TRUE;
线程ID
指定ID为0x080为开始,是否有必要?这是否跟ID的范围有关系
指定ID最大值为400h,0x080~0x400的范围内必然存在GDI线程?(俺用Kernel Detective看过确实必然至少有一个GDI线程)
从问题2引出的问题,GDI线程和非GDI线程的ID是否有固定的ID值范围?系统分配这个ID
值是否存在某些规律(俺听某人说是随机的,如果是随机的话,这种方法太大偶然性了)
还有代码中的ID递增方式是add dwThreadId, 4,通过观察,ID值确实有这样的规律,但是
不懂,这是固定的还是怎么样的?俺有没有必要去了解?
PVOID PsGetThreadWin32Thread(KTHREAD* Thread);这个返回KTHREAD后面的Wind2Thread指针,win32Thread保存线程有关GUI的一些信息,如果这个不为空就是GUI的线程了