windows 与 USB设备进行数据交换实现

2019-12-5 C++

需求:上位机通过USB与下位机进行数据交互

实现:

打开设备:


static LONG HidOpen(DWORD HidUsbMian, DWORD HidUsbSub)
{
//hid设备GUID
CString strHidPath(_T(""));
HDEVINFO deviceInfoSet = INVALID_HANDLE_VALUE;
PSP_DEVICE_INTERFACE_DETAIL_DATA pDeviceInterfaceDetailData = NULL;
SP_DEVINFO_DATA devinfoData;
SP_DEVICE_INTERFACE_DATA deviceInterfaceData;
ZeroMemory(&deviceInterfaceData, sizeof(SP_DEVICE_INTERFACE_DATA));
ZeroMemory(&devinfoData, sizeof(SP_DEVINFO_DATA));
devinfoData.cbSize = sizeof(SP_DEVINFO_DATA);
deviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
GUID interfaceClassGuid = {0x4d1e55b2, 0xf16f, 0x11cf, {0x88, 0xcb, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30} };
deviceInfoSet = SetupDiGetClassDevsA(&interfaceClassGuid, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
int deviceIndex = 0;
BOOL bExit = FALSE;
for ( ; bExit == FALSE; )
{
do
{
HANDLE writeHandle = INVALID_HANDLE_VALUE;
DWORD dwRequiredSize = 0;
BOOL res = SetupDiEnumDeviceInterfaces(deviceInfoSet,
NULL,
&interfaceClassGuid,
deviceIndex,
&deviceInterfaceData);
if (res == FALSE)
{
bExit = TRUE;
break;
}

BOOL bFind = FALSE;
for (int i = 0; ; ++i)
{
TCHAR szDriverName[MAX_PATH] = { 0 };
res = SetupDiEnumDeviceInfo(deviceInfoSet, i, &devinfoData);
if (res == FALSE)
{
break;
}
res = SetupDiGetDeviceRegistryProperty(deviceInfoSet, &devinfoData,
   SPDRP_CLASS, NULL, reinterpret_cast<PBYTE>(szDriverName), sizeof(szDriverName), NULL);
if (res == FALSE)
{
break;
}
if (_tcscmp(szDriverName, _T("HIDClass")) == 0) 
{
res = SetupDiGetDeviceRegistryProperty(deviceInfoSet, &devinfoData,
   SPDRP_DRIVER, NULL, reinterpret_cast<PBYTE>(szDriverName), sizeof(szDriverName), NULL);
if (res == TRUE)
{
bFind = TRUE;
break;
}
}
}
//不是有效的设备的继续
if (FALSE == bFind)
{
break;
}
res = SetupDiGetDeviceInterfaceDetail(deviceInfoSet,
&deviceInterfaceData,
NULL,
0,
&dwRequiredSize,
NULL);
pDeviceInterfaceDetailData = reinterpret_cast<PSP_DEVICE_INTERFACE_DETAIL_DATA>(malloc(dwRequiredSize));
pDeviceInterfaceDetailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
res = SetupDiGetDeviceInterfaceDetail(deviceInfoSet,
&deviceInterfaceData,
pDeviceInterfaceDetailData,
dwRequiredSize,
NULL,
NULL);

writeHandle = CreateFile(pDeviceInterfaceDetailData->DevicePath, 0, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
/*FILE_FLAG_OVERLAPPED,/*FILE_ATTRIBUTE_NORMAL,*/
if (writeHandle == INVALID_HANDLE_VALUE) 
{
break;
}
HIDD_ATTRIBUTES attrib;
attrib.Size = sizeof(HIDD_ATTRIBUTES);
HidD_GetAttributes(writeHandle, &attrib);
/*
if ((HidUsbMian == 0x0 || attrib.VendorID == HidUsbMian)
&& (HidUsbSub == 0x0 || attrib.ProductID == HidUsbSub))
*/
if (attrib.VendorID == HidUsbMian && attrib.ProductID == HidUsbSub)
{
strHidPath = pDeviceInterfaceDetailData->DevicePath;
}
CloseHandle(writeHandle);
} while (0);
if (pDeviceInterfaceDetailData != NULL)
{
free(pDeviceInterfaceDetailData);
pDeviceInterfaceDetailData = NULL;
}
if (strHidPath != _T(""))
{
break;
}
++deviceIndex;
}
if (strHidPath == _T(""))
{
return 0;
}

HANDLE openHandle = CreateFile(strHidPath, 
GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 
FILE_FLAG_OVERLAPPED, 0);
HANDLE readHandle = CreateFile(strHidPath, 
GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 
0, 0);
/*FILE_FLAG_OVERLAPPED,/*FILE_ATTRIBUTE_NORMAL,*/
if (openHandle == INVALID_HANDLE_VALUE)
{
return NULL;
}
do
{
PHIDP_PREPARSED_DATA ppData = NULL;
HIDP_CAPS caps;
if (0)//0 == HidD_SetNumInputBuffers(openHandle, 512))
{
::OutputDebugString(_T("-------------HidD_SetNumInputBuffers Failed-------\r\n"));
break;
}
if (0 == HidD_GetPreparsedData(openHandle, &ppData))
{
::OutputDebugString(_T("-------------HidD_GetPreparsedData Failed-------\r\n"));
break;
}

NTSTATUS ntStatus = HidP_GetCaps(ppData, &caps);
if (ntStatus != HIDP_STATUS_SUCCESS)
{
::OutputDebugString(_T("-------------HidP_GetCaps Failed-------\r\n"));
break;
}
{
CString strMsg(_T(""));
strMsg.Format(_T("--Input Length[%d]---Output Length[%d]----\r\n"), caps.InputReportByteLength, caps.OutputReportByteLength);
::OutputDebugString(strMsg);
}
HidD_FreePreparsedData(ppData);
PHidDevice dev = NewHidDevice();
if (dev != NULL)
{
dev->deviceHandle = openHandle;
dev->deviceReadHandle = readHandle;
int nBufLen = (strHidPath.GetLength() + 1);
dev->devicePath = new TCHAR[nBufLen];
if (dev->devicePath != NULL)
{
memset(dev->devicePath, 0, nBufLen * sizeof(TCHAR));
_tcscpy_s(dev->devicePath, nBufLen, strHidPath.GetString());
}
}
return reinterpret_cast<long>(dev);
} while (0);

if (openHandle != INVALID_HANDLE_VALUE)
{
CloseHandle(openHandle);
openHandle = INVALID_HANDLE_VALUE;
}
if (readHandle != INVALID_HANDLE_VALUE)
{
CloseHandle(readHandle);
readHandle = INVALID_HANDLE_VALUE;
}
return 0;
}
读数据:

ReadFile(handle, buf, 18, &dwReaded, NULL) ;

写数据:

OVERLAPPED ol;
memset(&ol, 0, sizeof(OVERLAPPED));
ol.hEvent = ::CreateEventA(NULL, TRUE, FALSE, NULL);
do
{
int nCurLen = nBufSize >= 8 ? 8 : nBufSize;
memset(buf, 0, 11);
buf[0] = 0x00;
buf[1] = LOBYTE(nCurLen);
buf[2] = 0x00;
memcpy(buf + 3, pTmp, nCurLen);
ResetEvent(ol.hEvent);
BOOL bRet = WriteFile(dev->deviceHandle, reinterpret_cast<LPVOID>(buf), 11, &dwWrited, &ol);
if (bRet == FALSE)
{
DWORD dwTmp = 0;
GetOverlappedResult(dev->deviceHandle, &ol, &dwTmp, TRUE);
}

pTmp += nCurLen;
nBufSize -= nCurLen;
} while (nBufSize > 0);

if (ol.hEvent != NULL)
{
CloseHandle(ol.hEvent);
}
坑1:

传输大数据时,在有的电脑,会出现卡死情况

解决方式:

读跟写句柄分开创建,具体原因不明  

标签: c++ USB 设备读写

评论(0) 浏览(641)

MFC 函数注入

2019-11-22 C++

问题:

USB 通信DLL代码找不到,无法知道通信协议

解决思路:

注入windows相关接口,查看通信过程中发送的协议

实现代码:比如注入CreateFile

typedef HANDLE(WINAPI * Real_CreateFile) (
LPCWSTR lpFileName,
DWORD dwDesiredAccess,
DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile);

1. 保存函数调用地址

BYTE g_oldJmp[6] = { 0 };
BYTE g_jmp[6] = { 0 };

2. 实现注入函数 执行函数前先恢复原接口函数地址,执行完再设置为更改后的地址

HANDLE WINAPI Routed_CreateFile(
LPCWSTR lpFileName,
DWORD dwDesiredAccess,
DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile)
{
CStringW strTmp(lpFileName);
HANDLE handle = NULL;
VirtualProtect((LPVOID)g_pOrigCreateFile, 6, g_myProtect, NULL); //ReadWrite again
memcpy(g_pOrigCreateFile, g_oldJmp, 6); //Unhook API
handle = CreateFileW(strTmp.GetString(), dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
memcpy(g_pOrigCreateFile, g_jmp, 6); //Rehook API
VirtualProtect((LPVOID)g_pOrigCreateFile, 6, g_oldProtect, NULL); //Normal setts
CStringW strMsg(_T(""));
strMsg.Format(L"%s %x %x %x %x %x\r\n", strTmp.GetString(), dwDesiredAccess, dwShareMode, handle, dwCreationDisposition, dwFlagsAndAttributes);
::OutputDebugStringW(strMsg);
return handle;
}


//注入接口
void BeginRedirect(LPVOID newFunction, LPVOID oldFunction, BYTE *jmp, BYTE *oldJmp)
{
BYTE tempJMP[6] = {0xE9, 0x90, 0x90, 0x90, 0x90, 0xC3}; 
memcpy(jmp, tempJMP, 6);
DWORD dwJMPSize = (reinterpret_cast<DWORD>(newFunction) - reinterpret_cast<DWORD>(oldFunction) - 5);
VirtualProtect(oldFunction, 6, PAGE_EXECUTE_READWRITE, &g_oldProtect);
//Change memory settings to make sure we can write the JMP in
memcpy(oldJmp, oldFunction, 6); //Copy old bytes before writing JMP
memcpy(&jmp[1], &dwJMPSize, 4); //Write the address to JMP to
memcpy(oldFunction, jmp, 6); //Write it in process memory
VirtualProtect((LPVOID)oldFunction, 6, g_oldProtect, NULL); //Change 
}

//初始化

g_pOrigCreateFile = reinterpret_cast<Real_CreateFile>(GetProcAddress(GetModuleHandle("Kernel32.dll"), "CreateFileW")); 
if (g_pOrigCreateFile != NULL)
{
BeginRedirect(Routed_CreateFile, g_pOrigCreateFile, g_jmp, g_oldJmp);
}

标签: c++ 函数hook

评论(0) 浏览(306)

wireshark抓包数据获取rtsp请求的视频流

2019-1-17 C++

lua脚本下载:https://github.com/volvet/h264extractor 

1. 安装wireshark软件

2. 编辑wireshark安装目录底下的init.lua,设置disable_lua = false;

3. 在init.lua的最后加上dofile(DATA_DIR.."rtp_h264_extractor.lua")

4. 把rtp_h264_extractor.lua放在wireshark同一路径下

5. 打开wireshark抓取的网络数据流

6.设置过滤条件分析:如rtsp.method == "PLAY" && ip.src == 1.1.1.1

获取ip地址为1.1.1.1请求的所有rtsp视频流

7.通过tcp端口获取要分析的视频流的所有交互数据:如tcp.port == 57109

获取通过57109该端口交互的rtsp视频流数据

8.导出该视频流数据:文件->导出特定分组 All packets Displayed

9.查看导出的数据视频流编码格式:

查找抓包数据服务端对客户端DESCRIBE请求的回复数据包,找到Media Attribute节点

查看编码是否H264,及type值 如96,如是H264则继续往下

10.设置H264的编码载体类型

编辑->首选项->Protocols->H264设置H264 dynamic payload types为96

11.导出H264数据裸流:工具->Extract h264 stream from RTP

12.在数据流的同一目录底下生成dump.264

13.打开vlc,设置分流器为H264

工具->偏好设置->全部(出来高级偏好设置)->输入/编解码器->分流器->分流模块->H264

14.编号生成的dump.264文件


标签: wireshark H264 rtsp

评论(0) 浏览(746)

CStdioFile Unicode ReadString 读取汉字乱码

2018-10-21 C++

     1. Unicode 模式下ReadString 需要使用typebinary读取文本,中文才不会乱码

        CStdioFile file;

        if (file.Open(filePath, CFile::modeRead | CFile::typeBinary) == TRUE)
        {
            CString strLine(_T(""));
            WORD sign;
            file.Read(&sign, 2);
            while (file.ReadString(strLine))
            {
                 m_listInfo.InsertString(m_listInfo.GetCount(), strLine);
            }
            file.Close();
        }

标签: MFC StdioFile ReadString

评论(0) 浏览(1500)

利用dll生成lib

2018-4-29 C++

业务场景:

使用libvlc3.02 SDK提供的lib及dll编译运行程序,提示找不到XXX于动态链接库libvlc.dll上

解决办法:

直接利用libvlc.dll生成libvlc.lib

步骤:

dumpbin.exe:dll导出函数

C:\Program Files (x86)\Microsoft Visual Studio 8\VC\bin>dumpbin libvlc.dll /EXPORTS /OUT:libvlc.def

编辑libvlc.def只留下函数所在的行

          1    0 00002B30 libvlc_add_intf
          2    1 0000BB60 libvlc_audio_equalizer_get_amp_at_index
          3    2 0000B980 libvlc_audio_equalizer_get_band_count

python:格式化def

file = open(r"D:\Beihai\python\libvlco.def")
files = open(r"D:\Beihai\python\libvlc.def", "w")
fc = 1
while 1 :
    line = file.readline()
    if not line :
        break
    sl = line.split()
    #print sl[-1]
    nl = sl[-1] + " @ " + str(fc) + "\n"
    fc = fc + 1
    files.write(nl)
file.close()
files.close()

lib:利用def生成lib

lib /def:libvlc.def /MACHINE:IX86 /out:libvlc.lib



标签: python c++ def dll

评论(0) 浏览(1029)

百度地图坐标与GPS坐标的转换

2018-3-25 C++

参考各种坐标的转换:https://blog.csdn.net/doulejian/article/details/70155080

GPS坐标在百度地图上显示位置:http://developer.baidu.com/map/jsdemo.htm#a5_2

获取百度地图坐标点:http://api.map.baidu.com/lbsapi/getpoint/index.html

#pragma once

static const double PI = 3.1415926535897932384626;
static const double A = 6378245.0;
static const double EE = 0.00669342162296594323;
class Gps
{
public:
Gps(void){}
~Gps(void){}
Gps(double wgLat, double wgLon)
{
SetWgLat(wgLat);
SetWgLon(wgLon);
}

double GetWgLat()
{
return m_wgLat;
}

void SetWgLat(double wgLat)
{
m_wgLat = wgLat;
}

double GetWgLon()
{
return m_wgLon;
}

void SetWgLon(double wgLon)
{
m_wgLon = wgLon;
}

Gps Transform(double lat, double lon)
{
if (TRUE == OutOfChina(lat, lon))
{
return Gps(lat, lon);
}

double dLat = TransformLat(lon - 105.0, lat - 35.0);
double dLon = TransformLon(lon - 105.0, lat - 35.0);
double radLat = lat / 180.0 * PI;
double magic = sin(radLat);
magic = 1 - EE * magic * magic;
double sqrtMagic = sqrt(magic);
dLat = (dLat * 180.0) / ((A * (1 - EE)) / (magic * sqrtMagic) * PI);
dLon = (dLon * 180.0) / (A / sqrtMagic * cos(radLat) * PI);
double mgLat = lat + dLat;
double mgLon = lon + dLon;
return Gps(mgLat, mgLon);
}

double TransformLat(double x, double y)
{
double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y
+ 0.2 * sqrt(abs(x));
ret += (20.0 * sin(6.0 * x * PI) + 20.0 * sin(2.0 * x * PI)) * 2.0 / 3.0;
ret += (20.0 * sin(y * PI) + 40.0 * sin(y / 3.0 * PI)) * 2.0 / 3.0;
ret += (160.0 * sin(y / 12.0 * PI) + 320 * sin(y * PI / 30.0)) * 2.0 / 3.0;
return ret;
}

double TransformLon(double x, double y)
{
double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y
+ 0.1 * sqrt(abs(x));
ret += (20.0 * sin(6.0 * x * PI) + 20.0 * sin(2.0 * x * PI)) * 2.0 / 3.0;
ret += (20.0 * sin(x * PI) + 40.0 * sin(x / 3.0 * PI)) * 2.0 / 3.0;
ret += (150.0 * sin(x / 12.0 * PI) + 300.0 * sin(x / 30.0 * PI)) 
* 2.0 / 3.0;
return ret;
}

BOOL OutOfChina(double lat, double lon) 
{
if (lon < 72.004 || lon > 137.8347)
{
return TRUE;
}
if (lat < 0.8293 || lat > 55.8271)
{
return TRUE;
}
return FALSE;
}

Gps Bd09ToGcj02(double bdLat, double bdLon)
{
double x = bdLon - 0.0065;
double y = bdLat - 0.006;
double z = sqrt(x * x + y * y) - 0.00002 * sin(y * PI);
double theta = atan2(y, x) - 0.000003 * cos(x * PI);
double ggLon = z * cos(theta);
double ggLat = z * sin(theta);
return Gps(ggLat, ggLon);

}

Gps Gcj02ToGps84(double bdLat, double bdLon)
{
Gps gps = Transform(bdLat, bdLon);
double lon = bdLon * 2 - gps.GetWgLon();
double lat = bdLat * 2 - gps.GetWgLat();
return Gps(lat, lon);
}

Gps Bd09ToGps84()
{
Gps gcj02 = Bd09ToGcj02(m_wgLat, m_wgLon);
Gps map84 = Gcj02ToGps84(gcj02.GetWgLat(), gcj02.GetWgLon());
return map84;
}

private:
double m_wgLat;
double m_wgLon;
};


标签: 百度坐标 GPS

评论(0) 浏览(1444)

windows程序崩溃时产生dmp

2017-12-30 C++

需求:windows程序崩溃时产生dmp

解决方案:

stdafx.h增加如下内容:

#include <Dbghelp.h>

//异常dmp捕获
void SetMyUnhandledExceptionFilter();

stdafx.cpp增加如下内容:

//生产DUMP文件
int GenerateMiniDump(HANDLE hFile, PEXCEPTION_POINTERS pExceptionPointers, PTCHAR pwAppName)
{
BOOL bOwnDumpFile = FALSE;
HANDLE hDumpFile = hFile;
MINIDUMP_EXCEPTION_INFORMATION ExpParam;

typedef BOOL(WINAPI * MiniDumpWriteDumpT)(
HANDLE,
DWORD,
HANDLE,
MINIDUMP_TYPE,
PMINIDUMP_EXCEPTION_INFORMATION,
PMINIDUMP_USER_STREAM_INFORMATION,
PMINIDUMP_CALLBACK_INFORMATION
);

MiniDumpWriteDumpT pfnMiniDumpWriteDump = NULL;
HMODULE hDbgHelp = LoadLibrary(_T("DbgHelp.dll"));
if(NULL == hDbgHelp)
{
return EXCEPTION_EXECUTE_HANDLER;
}

pfnMiniDumpWriteDump = (MiniDumpWriteDumpT)GetProcAddress(hDbgHelp, "MiniDumpWriteDump");
if(NULL == pfnMiniDumpWriteDump)
{
return EXCEPTION_EXECUTE_HANDLER;
}

if(hDumpFile == NULL || hDumpFile == INVALID_HANDLE_VALUE)
{
TCHAR szFileName[MAX_PATH] = { 0 };
TCHAR* szVersion = _T("v1.0");
int dwBufferSize = MAX_PATH;
SYSTEMTIME stLocalTime = { 0 };

GetLocalTime(&stLocalTime);

//wsprintf(szFileName, L"%s%s", szPath, szAppName);
//CreateDirectory(szFileName, NULL);
_stprintf_s(szFileName, MAX_PATH, _T("%s-%s-%04d%02d%02d-%02d%02d%02d-%ld-%ld.dmp"),
pAppName,
szVersion,
stLocalTime.wYear, stLocalTime.wMonth, stLocalTime.wDay,
stLocalTime.wHour, stLocalTime.wMinute, stLocalTime.wSecond,
GetCurrentProcessId(), GetCurrentThreadId());
hDumpFile = CreateFile(szFileName, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_WRITE | FILE_SHARE_READ, 0, CREATE_ALWAYS, 0, 0);
}

if(hDumpFile != INVALID_HANDLE_VALUE)
{
ExpParam.ThreadId = GetCurrentThreadId();
ExpParam.ExceptionPointers = pExceptionPointers;
ExpParam.ClientPointers = FALSE;

pfnMiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(),
hDumpFile, MiniDumpWithDataSegs, (pExceptionPointers ? &ExpParam : NULL), NULL, NULL);

CloseHandle(hDumpFile);
}

if(hDbgHelp != NULL)
{
FreeLibrary(hDbgHelp);
}
return EXCEPTION_EXECUTE_HANDLER;
}

LONG WINAPI ExceptionFilter(LPEXCEPTION_POINTERS lpExceptionInfo)
{
if (IsDebuggerPresent())
{
return EXCEPTION_CONTINUE_SEARCH;
}

return GenerateMiniDump(NULL, lpExceptionInfo, _T("XXXXX"));
}



void DisableSetUnhandledExceptionFilter()
{
 void *addr = (void*)GetProcAddress(LoadLibrary(_T("kernel32.dll")) ,"SetUnhandledExceptionFilter");
if(addr)
{
unsigned char code[16] = { 0 };
int size = 0;
code[size++] = 0x33;
code[size++] = 0xC0;
code[size++] = 0xC2;
code[size++] = 0x04;
code[size++] = 0x00;

DWORD dwOldFlag,dwTempFlag;
VirtualProtect(addr, size, PAGE_READWRITE, &dwOldFlag);
WriteProcessMemory(GetCurrentProcess(), addr, code, size, NULL);
VirtualProtect(addr, size, dwOldFlag ,&dwTempFlag);
}
}


void SetMyUnhandledExceptionFilter()
{
SetUnhandledExceptionFilter(NULL);
SetUnhandledExceptionFilter(&ExceptionFilter);
DisableSetUnhandledExceptionFilter();
}

程序入口添加如下内容:

SetMyUnhandledExceptionFilter();

程序所在目录添加:DbgHelp.dll文件



标签: MFC dmp windows

评论(0) 浏览(15928)

git 基本操作记录

2017-12-9 C++

1. 创建空版本库方便上传已有版本库代码

git init --bare

2.项目代码加入git版本控制

git init //初始化git版本库

git add . //把当前项目文件夹内的文件加入版本控制

git commit -m "备注" //提交所有代码到版本库

3. 提交代码到远程版本库

git remote add usb h:\gitres\xxx //usb 远程版本库标识 h:\gitres\xxx 远程版本库位置

git push usb master //提交代码到远程版本库

4. 下载合并远程版本库变动到本体

git fetch usb :tmp //先下载远程版本库到tmp分支

git diff tmp    //刚获取的远程版本库跟本地文件的差异

git merge tmp    //合并远程版本库代码到本地

5. 新建分支切换

git checkout -b newbranch

6. 放弃当前修改

git checkout . //放弃所有的修改

git checkout -- file //放弃文件file的改动

标签: git

评论(0) 浏览(1195)

ado open 连接数据库卡住

2017-12-3 C++

情景:

程序采用ado访问access数据库

现象:

公司编译生成的程序在公司的电脑上运行没问题,但是到了客户的电脑上运行就卡住!

解决办法:

通过打印调试信息,发现程序是卡在数据库open的时候,就不往下走了!

对比了下ado版本,发现客户电脑上的ado版本比公司编译环境的低!

替换掉客户端电脑上的msado.dll,问题解决

标签: MFC ado windows

评论(0) 浏览(1182)

windbg调试句柄泄露

2017-11-22 C++

场景:程序运行后句柄一直往上增加,导致程序崩溃 解决办法:利用windbg提供的!htrace,分析未关闭的句柄 帮助:windbg命令行输入!htrace -?可以查看帮助 步骤: 使用windbg打开要调试的程序 1 在命令行输入”!htrace -enable” 打开句柄回溯 2 输入g启动程序运行 3 运行一会儿后正常关闭程序 4 输入!htrace 查看打开的句柄 5 输入!htrace -diff 分析未关闭的句柄

标签: windbg 调试 句柄泄露

评论(0) 浏览(1120)

Powered by EMLOG Copyright @ 狼酒 版权所有. 闽ICP备14012694号-2