dword

常用的时间类型转换

◇◆丶佛笑我妖孽 提交于 2019-12-03 23:16:58
在程序开发过程中不断会碰到不同的数据间的转换,在这里做一个总结: 一.时间类型间的转换: 1.time_t 转 FILETIME FILETIME ft; LONGLONG ll = Int32x32To64(t, 10000000) + 116444736000000000; ft.dwLowDateTime = (DWORD) ll; ft.dwHighDateTime = (DWORD)(ll >> 32); 2.FILETIME 转 time_t FILETIME ft; time_t t; LONGLONG llTime = ft.dwHighDateTime; llTime <<= 32; llTime |= ft.dwLowDateTime; t = (DWORD)((LONGLONG)(llTime - 116444736000000000) / 10000000); 3. SYSTEMTIME 转 FILETIME FILETIME ft; SYSTEMTIME st ; SystemTimeToFileTime( &st, &ft ); 4. FILETIME 转 SYSTEMTIME FILETIME ft; SYSTEMTIME st ; FileTimeToSystemTime( &ft, &st); 5.DATE 转 SYSTEMTIME DATE

C++多态:深入虚函数,理解晚绑定

可紊 提交于 2019-12-03 21:59:11
 C++的多态特性是通过晚绑定实现的。晚绑定(late binding),指的是编译器或解释器程序在运行前,不知道对象的类型。使用晚绑定,无需检查对象的类型,只需要检查对象是否支持特性和方法即可。  在C++中,晚绑定通常发生在使用 virtual 声明成员函数时。此时,C++创建一个虚函数表,当某个函数被调用时需要从这个表中查找该函数的实际位置。通常,晚绑定也叫做动态函数分派(dynamic dispatch)。  考虑如下的代码: #include<iostream> using namespace std ; class D { public : int num; D( int i = 0 ) { num = i; } virtual void print() { cout << "I'm a D. my num=" << num << endl; }; }; class E : public D { public : E( int i = 0 ) { num = i; } void print() { cout << "I'm a E. my num=" << num << endl; } void ppp() { int ttt = 1 ; } }; int main() { void (D::*i)() = &D::print; E* e = new E( 1 ); e

逆向-逻辑流控制

假如想象 提交于 2019-12-03 14:05:38
逻辑流控制 在我的抽象中执行逻辑有三种-顺序、选择、循环。默认汇编就是从上到下顺序执行,选择用if-else和switch,循环用while、for等。 分支语句 if-else int main(int argc, char const *argv[]) { int a=10; if (a>10){ printf("a>10"); }else{ printf("a<=10"); } return 0; int main(int argc, char const *argv[]) { int a=10; if (a>10){ printf("a>10"); }else if(a<2){ printf("a<2"); }else{ printf("2<=a<=10"); } return 0; } 从上面两个二分支和三分支可以看出: 开始标志就是cmp,jcc 这两条标志语句,代表条件判断。 直接跳转的jmp代表执行的是它上面的分支。 每个分支内jmp跳的地址是一样的都是else{};这条语句之后的位置。 巧妙的运用了顺序结构 switch int main(int argc, char const *argv[]) { int a=11; switch (a) { case 10: printf("a=10"); break; case 11: printf("a=11");

How to retrieve information from multiple/dual code signatures on an executable file

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've been using the following code (taken from KB323809 article ) to retrieve information about the code signature on the executable file. This works fine for a single digital signature. But how to retrieve information for multiple code signatures? In that case the Microsoft code below simply retrives info only for the first signature. My thought was to call CryptMsgGetParam with CMSG_SIGNER_COUNT_PARAM to get the number of signatures and then pass each signature index to the subsequent call to CryptMsgGetParam with CMSG_SIGNER_INFO_PARAM

How to get current CPU and RAM usage in C++?

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: is it possible, in C++, to get the current RAM and CPU usage? Is there a platform-indepentent function call? 回答1: There is an open source library that gives these (and more system info stuff) across many platforms: SIGAR API I've used it in fairly large projects and it works fine (except for certain corner cases on OS X etc.) 回答2: Sadly these things rely heavily on the underlying OS, so there are no platform-independent calls. (Maybe there are some wrapper frameworks, but I don't know of any.) On Linux you could have a look at the

C++ 杂项

谁说胖子不能爱 提交于 2019-12-03 06:21:28
#include <iostream> #define Main main #define COLOR_GREEN system("color 2"); #include <vector> #include <list> #include <WinSock2.h> #include <WS2tcpip.h> #include <LM.h> #include <winnetwk.h> #include "BitMap.h" #include <wlanapi.h> #include "ATBAudioEngine/ATBAudioEngine.h" #pragma comment(lib,"Ws2_32.lib") #pragma comment(lib,"Mpr.lib") #pragma comment(lib,"netapi32.lib") #pragma comment(lib,"Wlanapi.lib") #include <Windows.h> class disorderly { int m_buf[10] = { 0 }; public: void initBuf() { srand(GetTickCount()); int len = sizeof(m_buf) / sizeof(int); for (int i = 0; i < len; i++) { m_buf

用户模拟异常的记录

被刻印的时光 ゝ 提交于 2019-12-03 04:29:35
用户模拟异常的记录   我们现在来分析一下用户模拟异常 1. 测试代码 1 #include "pch.h" 2 #include <iostream> 3 void exceptiontest() { 4 throw 1; 5 6 } 7 int main() 8 { 9 10 exceptiontest(); 11 } 二、分析过程 1. 使用 visual Studio 在 "throw 1"处下断点启动调试  throw 1;   00D91808 mov dword ptr [ebp-0C8h],1   00D91812 push offset __TI1H (0D99018h)   00D91817 lea eax,[ebp-0C8h]   00D9181D push eax   00D9181E call __CxxThrowException@8 (0D9139Dh)  可以看到其首先进行了两个步骤:   1)创建了一个局部变量1。   2)向 __CxxThrowException@8 函数传入了一个 偏移地址 offset __TI1H (0D99018h) ,和 局部变量1 的地址。 2. 分析 _CxxThrowException函数传入参数:   _CxxThrowException( void* pExceptionObject, // The

Should DWORD map to int or uint?

六眼飞鱼酱① 提交于 2019-12-03 04:18:53
When translating the Windows API (including data types) into P/Invoke, should I replace DWORD with int or uint ? It's normally unsigned, but I see people using int everywhere instead (is it just because of the CLS warning? even the .NET Framework itself does this ), and so I'm never really sure which one is the correct one to use. Well according to the MSDN DWORD is an unsigned integer with a range of 0 to 4294967295. So ideally you should replace it with uint rather than int . However, as you have spotted uint is non-CLS compliant so if your method is publicly visible you should use int and

通过导出表找导出函数

梦想与她 提交于 2019-12-03 03:57:46
例如:一个HelloDll.dll 其导出表信息如下: 该dll有4个函数; 用.def的方式导出; 其中有个匿名函数; 1.分析 导入dll中的函数有两种方式: 1】通过序号 2】通过函数名 例如:显式链接dll时使用的库函数“GetProcAddress”实现了用函数的查找; myPlus = (lpPlus)GetProcAddress(hModule, "_Plus@8"); 其中的参数hModule实际上是pe文件拉伸后的起始位置ImageBase; 2.通过函数名导入 思路: 遍历名字表,获取函数名,与目标函数名比对,如果有相同的函数名,获得该函数名在名字表中的索引; 注意:名字表中储存的是函数名的内存镜像中相对ImageBase的偏移地址,需要转换成文件镜像偏移地址; 用获得的索引在序号表中找到该函数对应的序号; 以序号为索引在函数地址表中找到函数的地址; 注意:函数地址表中储存的是函数内存镜像的偏移地址,需要转换为文件镜像的偏移地址; 用函数指针接收函数的地址; 使用函数; 函数: GetFunctionAddrByName(FileBuffer指针,函数名指针) 代码: #include "stdafx.h" #include "PeTool.h" #include "string.h" #define SRC "C:\\Users\\Administrator\

Media Foundation webcam video H264 encode/decode produces artifacts when played back

匿名 (未验证) 提交于 2019-12-03 03:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a solution, where I encode video (YUY2) samples from a webcam with Media Foundation's h264 encoder. Then I send it via TCP connection to another application that decodes the stream with Media Foundation's h264 decoder back to YUY2 format. After decoding, the video samples/images are presented at the screen using DirectX. The problem is that between key-frames the video image gets increasing amount of artifacts. Artifacts disappear when a key-frame is received. I dropped the TCP connection out of the scope and did the decoding