2011-06-07 00:48:10 +08:00
|
|
|
#include "stdafx.h"
|
|
|
|
|
|
|
|
#include <intrin.h>
|
|
|
|
|
|
|
|
#include <iostream>
|
2011-09-22 16:25:42 +08:00
|
|
|
#include <string>
|
2011-06-07 00:48:10 +08:00
|
|
|
|
|
|
|
#include "utils.h"
|
|
|
|
|
2011-09-22 16:25:42 +08:00
|
|
|
const ULONG g_constNumValue = 0x5555;
|
|
|
|
const bool g_constBoolValue = true;
|
|
|
|
|
|
|
|
UCHAR g_ucharValue = 1;
|
|
|
|
USHORT g_ushortValue = 2;
|
|
|
|
ULONG g_ulongValue = 4;
|
|
|
|
ULONGLONG g_ulonglongValue = 8;
|
|
|
|
|
|
|
|
std::string g_string;
|
|
|
|
|
2011-09-22 18:05:56 +08:00
|
|
|
struct structWithBits {
|
|
|
|
ULONG m_bit0_4 : 5;
|
|
|
|
ULONG m_bit5 : 1;
|
|
|
|
ULONG m_bit6_7 : 2;
|
|
|
|
};
|
|
|
|
structWithBits g_structWithBits = {0};
|
|
|
|
|
2011-09-22 19:20:31 +08:00
|
|
|
union unionTest {
|
|
|
|
ULONG m_value;
|
|
|
|
structWithBits m_bits;
|
|
|
|
};
|
|
|
|
|
|
|
|
class classBase {
|
|
|
|
public:
|
|
|
|
int m_baseField;
|
|
|
|
void baseMethod() const {}
|
|
|
|
virtual void virtFunc() = 0;
|
|
|
|
virtual void virtFunc2() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct structTest {
|
|
|
|
ULONG m_field0;
|
|
|
|
ULONGLONG m_field1;
|
|
|
|
bool m_field2;
|
|
|
|
USHORT m_field3;
|
|
|
|
};
|
|
|
|
|
|
|
|
class classChild : public classBase {
|
|
|
|
public:
|
|
|
|
int m_childField;
|
|
|
|
int m_childField2;
|
|
|
|
void childMethod() const {}
|
|
|
|
virtual void virtFunc() {}
|
|
|
|
virtual void virtFunc2() {}
|
|
|
|
};
|
|
|
|
|
2011-09-22 22:38:42 +08:00
|
|
|
struct struct2 {
|
|
|
|
structTest m_struct;
|
|
|
|
unionTest m_union;
|
|
|
|
int m_field;
|
|
|
|
};
|
|
|
|
|
2011-09-22 00:50:42 +08:00
|
|
|
void FuncWithName0()
|
|
|
|
{
|
2011-09-22 19:20:31 +08:00
|
|
|
classChild _classChild;
|
|
|
|
_classChild.baseMethod();
|
|
|
|
|
|
|
|
reinterpret_cast<classChild *>(&_classChild)->virtFunc2();
|
2011-09-23 22:26:55 +08:00
|
|
|
std::cout << _classChild.m_childField2;
|
|
|
|
std::cout << g_constNumValue;
|
|
|
|
std::cout << g_constBoolValue;
|
|
|
|
std::cout << g_ucharValue;
|
|
|
|
std::cout << g_ushortValue;
|
|
|
|
std::cout << g_ulongValue;
|
|
|
|
std::cout << g_ulonglongValue;
|
2011-09-22 00:50:42 +08:00
|
|
|
}
|
|
|
|
|
2011-09-23 05:54:27 +08:00
|
|
|
void FuncWithName1(int a)
|
2011-09-22 00:50:42 +08:00
|
|
|
{
|
2011-09-23 22:26:55 +08:00
|
|
|
unionTest _unionTest[2] = {0};
|
2011-09-23 22:16:29 +08:00
|
|
|
_unionTest[1].m_value = 0;
|
2011-09-22 19:20:31 +08:00
|
|
|
structTest _structTest;
|
2011-09-23 05:54:27 +08:00
|
|
|
_structTest.m_field1 = a;
|
2011-09-22 22:38:42 +08:00
|
|
|
struct2 _struct2;
|
|
|
|
RtlZeroMemory(&_struct2, sizeof(_struct2));
|
2011-09-23 22:26:55 +08:00
|
|
|
|
|
|
|
std::cout << _unionTest[0].m_value;
|
|
|
|
std::cout << _structTest.m_field1;
|
|
|
|
std::cout << _struct2.m_struct.m_field1;
|
|
|
|
std::cout << g_string;
|
2011-09-22 00:50:42 +08:00
|
|
|
}
|
|
|
|
|
2011-06-07 00:48:10 +08:00
|
|
|
int _tmain(int argc, _TCHAR* argv[])
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2011-08-15 01:52:03 +08:00
|
|
|
// Let test scripts to execute
|
|
|
|
__debugbreak();
|
2011-09-22 00:50:42 +08:00
|
|
|
FuncWithName0();
|
2011-09-23 05:54:27 +08:00
|
|
|
FuncWithName1(2);
|
2011-06-07 00:48:10 +08:00
|
|
|
}
|
|
|
|
catch(std::exception & ex)
|
|
|
|
{
|
|
|
|
std::cout << ex.what() << std::endl;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
std::cout << "Unknown error" << std::endl;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|