1 | cd %~dp0 |
1 | set DEPOT_TOOLS_UPDATE = 0 |
参数设置
1 |
|
1.AmbientLightAware 光亮感应器 平板设备等根据环境调整应用程序
2.AmsiProvider AmsiStream 杀软接口
3.AppxPacking 打包相关
4.Background Intelligent Transfer Service 后台智能传输服务后台下载 xp支持 没看到什么应用使用Bits.h 但是确实能用,可以在应用程序退出后空闲时间继续下载(依赖服务Background Intelligent Transfer Service)Windows.Networking.BackgroundTransfer UWP开发使用
5.
]]>Prometheus https://prometheus.io/ 服务器监控
Graphite
图表 Grafana https://github.com/grafana/grafana
我们以vs2015编译的程序为例
msvcp140.dll 可进一步拆分为ucrtbase.dll + vcruntime.dll
msvcr140.dll 一般是指运行时库
ucrtbase.dll c和cpp函数集合
vcruntime.dll vc++的运行时
windows api set 系列的dll 如 api—ms-,ext—.dll 一般不需要直接打包到进去,每个系统的版本号可能不一致,且该系列dll不是直接干活的而是转发调用系统核心
当缺少以上任意dll时,用户不应该手动去第三方网站下载,程序员应该提供所需的dll打包到目录,用户可以去微软下载安装对应版本的vcredist2015_x86.exe vcredist2015_x64.exe
当安装成功vcredist 检测c盘 windows/system32目录下会多出以下文件
看了几个编译脚本都依赖了msys2
https://github.com/microsoft/FFmpegInterop //Interop 交互
模拟linux环境的工具可替代msys,MinGW,Cygwin 下载地址https://www.msys2.org/
ps: 这玩意居然91.3MB WHAT IS THIS?
https://trac.ffmpeg.org/wiki/CompilationGuide
https://www.ffmpeg.org/platform.html#Microsoft-Visual-C_002b_002b-or-Intel-C_002b_002b-Compiler-for-Windows
1 | #过程较慢 更新很多组件 |
经常记不住性能特点,数据来源https://linuxreviews.org/Comparison_of_Compression_Algorithms
algorithm | time | size | binary | parameters | info |
---|---|---|---|---|---|
algorithm | time | size | binary | parameters | info |
none | 0m0.934s | 939M | just tar | cf | tar itself is an archiving tool, you do not need to compress the archives |
gzip | 0m23.502s | 177M | gzip | cfz | |
gzip | 0m3.132s | 177M | pigz | c -Ipigz -f | pigz 2.4 |
bzip2 | 1m0.798s | 134M | bzip2 | cfj | Standard bzip2 will only use one core (at 100%) |
bzip2 | 0m9.091s | 135M | pbzip2 | c -Ipbzip2 -f | Parallel bzip2. RAM usage topped out at about 900 MiB RAM. |
lz4 | 0m3.914s | 287M | lz4 | c -I”lz4” -f | Really fast but the resulting archive is barely compressed. Worst compression king. |
lz4 | 0m56.506s | 207M | lz4 | c -I”lz4 -12” -f | Supports levels -[1-12].Uses 1 core, does not appear to be any multi-threaded variant(?) |
lzip | 4m42.017s | 116M | lzip | c –lzip -f | v1.21. Standard lzip will only use one core (at 100%). Very slow. |
lzip | 0m42.542s | 118M | plzip | c -Iplzip -f | plzip 1.8 (Parallel lzip), default level -6 |
lzip | 1m39.697s | 110M | plzip | c -I”plzip -9” -f | Parallel lzip at best compression -9. plzip process used 5.1 GiB RAM at its maximum. |
xz | 5m2.952s | 114M | xz | cfJ | Standard xz will only use one core (at 100%). Unbearably slow. |
xz | 0m53.569s | 115M | pxz | c -Ipxz -f | Parallel PXZ 4.999.9beta. Process used 1.4 GiB RAM at its maximum. |
xz | 1m33.441s | 110M | pxz | c -I”pxz -9” -f | Parallel PXZ 4.999.9beta using its best possible compression. pxz process topped out at 3.5 GiB resident. |
zstd | 0m3.034s | 167M | zstd | c –zstd -f | zstd uses 1 core if it is no told otherwise with -T# where # is a thread number and 0 means all cores (not all threads) |
zstd | 1m18.238s | 117M | zstd | c -I”zstd -19 -T0” -f | -19 gives the best possible compression, -T0 utilizes all cores. |
压缩体积
压缩
解压缩
configure -prefix D:\QtSource\build -debug-and-release -opensource -static -force-debug-info -opengl dynamic -platform win32-msvc -c++std c++11 -skip qtmultimedia -skip qtsensors -skip qtwebengine -skip qtgamepad -nomake tests -mp -skip qtlocation -skip qtserialbus -confirm-license
1 | Configure meta: |
3.
]]>PhInitializePhLibEx
PhInitializeWindowsVersion RtlGetVersion
PhInitializeSystemInformation NtQuerySystemInformation
PhHeapInitialization RtlCreateHeap RtlSetHeapInformation
PhQueuedLockInitialization NtCreateKeyedEvent PhQueuedLockSpinCount = 2000
PhRefInitialization RtlInitializeSListHead PhInitializeFreeList TlsAlloc KUSER_SHARED_DATA 内核共享区域
PhBaseInitialization
NtCreateMutant
PhGuiSupportInitialization PhCreateHashtable
PhSettingsInitialization PhAddDefaultSettings PhUpdateCachedSettings
PeInitializeSettings 初始化参数 appdata中xml配置
PvPropInitialization
PhTreeNewInitialization
PhLoadMappedImageEx PhMapViewOfEntireFile
#define IMAGE_DOS_SIGNATURE 0x5A4D // MZ
#define IMAGE_ELF_SIGNATURE 0x457f // “\x7fELF”
PvPeProperties
PrivateExtractIconExW 获取图标user32.dll
PvpLoadDbgHelp InitializeListHead PhInitializeQueuedLock PhInitializeAvlTree
PhLoadModuleSymbolProvider PhfAcquireFastLockExclusive 锁定pdb
PvCreatePropContext
PHP_BASE_THREAD_DBG teb processid threadid
PhInitializePhLibEx(同上)
PhInitializeDirectoryPolicy GetApplicationDirectory SetCurrentDirectory
PhInitializeExceptionPolicy WIN7以上 GetErrorMode RtlSetUnhandledExceptionFilter
PhInitializeNamespacePolicy mutex
PhInitializeMitigationPolicy //Mitigation:缓解 https://docs.microsoft.com/windows/security/threat-protection/overview-of-threat-mitigations-in-windows-10
PhInitializeRestartPolicy //vista 因为更新等原因重启后 重新启动计算机应用程序 RegisterApplicationRestart EWX_RESTARTAPPS
一般方式: WM_QUERYENDSESSION RegisterApplicationRestart 系统重启是用ExitWindowsEx+EWX_RESTARTAPPS 或者InitiateShutdown+SHUTDOWN_RESTARTAPPS
PhInitializeAppSystem
PhProcessProviderInitialization
PhProcessImageListInitialization
PhServiceProviderInitialization
PhNetworkProviderInitialization
一个完整的集中式日志系统,需要包含以下几个主要特点:
ELK Elasticsearch + Logstash + Kibana
Elasticsearch 是个开源分布式搜索引擎,提供搜集、分析、存储数据三大功能。它的特点有:分布式,零配置,自动发现,索引自动分片,索引副本机制,restful风格接口,多数据源,自动搜索负载等。
Logstash 主要是用来日志的搜集、分析、过滤日志的工具,支持大量的数据获取方式。一般工作方式为c/s架构,client端安装在需要收集日志的主机上,server端负责将收到的各节点日志进行过滤、修改等操作在一并发往elasticsearch上去
Kibana 也是一个开源和免费的工具,Kibana可以为 Logstash 和 ElasticSearch 提供的日志分析友好的 Web 界面,可以帮助汇总、分析和搜索重要数据日志
Filebeat隶属于Beats。目前Beats包含四种工具:
Packetbeat(搜集网络流量数据)
Topbeat(搜集系统、进程和文件系统级别的 CPU 和内存使用情况等数据)
Filebeat(搜集文件数据)
Winlogbeat (搜集 Windows 事件日志数据)
elastic/beats https://github.com/elastic/beats
]]>昨天在翻阅taiga源代码的时候发现了一个神奇的Windows API Beep函数, 突然想到曾经有人跟我说过可以用Beep播放一首歌曲,
回忆起小时候用计算器的按键音当成各种调子按下,模拟音乐的简单快乐。
于是我便看了这份代码播放的音乐,当点击ICON图标时播放一首orange歌曲。
(猜测应该是这首https://c.y.qq.com/base/fcgi-bin/u?__=9xGuYfR)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
namespace BeepMusic
{
constexpr std::array<std::pair<int, float>, 32> notes{{
{84, 1 / 2.f}, {84, 1 / 4.f}, {86, 1 / 8.f}, {84, 1 / 4.f},
{82, 1 / 4.f}, {81, 1 / 4.f}, {77, 1 / 8.f}, {79, 1 / 8.f},
{72, 1 / 8.f}, {77, 1 / 2.f}, {76, 1 / 8.f}, {77, 1 / 8.f},
{79, 1 / 8.f}, {81, 1 / 4.f}, {79, 1 / 4.f}, {77, 1 / 4.f},
{79, 1 / 4.f}, {81, 1 / 8.f}, {84, 1 / 2.f}, {84, 1 / 4.f},
{86, 1 / 8.f}, {84, 1 / 4.f}, {82, 1 / 4.f}, {81, 1 / 4.f},
{77, 1 / 8.f}, {79, 1 / 8.f}, {72, 1 / 8.f}, {77, 1 / 2.f},
{76, 1 / 8.f}, {77, 1 / 8.f}, {76, 1 / 8.f}, {74, 1 / 2.f},
}};
void playOrange()
{
constexpr auto get_frequency = [](const int note) {
if (note < 0 || note > 119) return -1.0f;
return 440.0f *
std::pow(2.0f, static_cast<float>(note - 57) / 12.0f);
};
constexpr auto get_duration = [](const float duration) {
return 1600 * duration;
};
for (const auto& [note, duration] : notes)
{
::Beep(static_cast<DWORD>(get_frequency(note)),
static_cast<DWORD>(get_duration(duration)));
}
}
} // namespace BeepMusic
其中有个公式
$$
440 \times 2 ^ {\frac{(x-57)}{12}}
$$
哪来的?
经反复查找资料
MIDI代表乐器数字接口。该标准指定了软件和电子设备可以传输和接收音乐的方式。
另外一个公式在开源项目 audacity
$$
440 \times 2 ^ {\frac{(x-69)}{12}}
$$
这个2个公式本身是什么逻辑,哪里来的,很难猜到,需要了解乐理知识
乐音体系: 有固定音高的音(乐音)的总和,叫做乐音体系。 一般的钢琴 88琴键 $A_2 - C^5$
音级: 在乐音体系中的每个音,就叫做“音级”。音级包括有基本音级和变化音级两种。 自然
音列:将乐音体系中的音,依照音高关系和次序,由低到高(上行)或由高向低(下行)排列起来,叫做“音列”。
半音: 在整个乐音体系中,相邻的两个音级(不论基本音级或变化音级)之间的音高关系就是“半音”,半音是音高关系中的最小单位。用分数1/2来标记。
全音: 在乐音体系中,两个半音相加,就形成了全音。用阿拉伯数字1来标记。
音名: 在乐音体系中,七个具有独立名称的音级叫做基本音级(也叫自然音级) “C D E F G A B” 钢琴白键都是基本音级
变化音级: # 升音级 $^#C$ 升半音 , b 降音级 $^bD$ 降半音 , # 重升音级 $^×E$ 升Q全音 , bb 重降音级 $^{bb}F$ 降半音
大谱钢琴键盘对照表
中央C 440Hz 第一国际高音
小字a $a^1 = 435 hz$ 第二国际高音 演奏会音高
西洋乐器
五度相生律又叫“三分损益律”,它是按纯五度的关系向上或向下推算的办法,来找出整个各个音级的精确高度。即是用分音列中第二分音与第三分音之间的音高关系,连续相生而求得出的各个音级的准确音高。 民族乐器。
将纯八度分成十二个均等的部分的音律叫做十二平均律。其中每一个部分就是一个半音,每个半音的距离是相等的,它的最大好处是转调方便。十二平均律多用在钢琴、手风琴、电子琴、风琴。
1
2
3
4
5
6
float midi[127];
int a = 440; // a is 440 hz...
for (int x = 0; x < 127; ++x)
{
midi[x] = (a / 32) * (2 ^ ((x - 9) / 12));
}
公式
$$
\frac{440}{32} \times 2 ^ {\frac{(x-9)}{12}}
$$
MIDI MIDI MIDI Note Frequency Note Frequency Note Frequency C1 0 8.1757989156 12 16.3515978313 24 32.7031956626 Db 1 8.6619572180 13 17.3239144361 25 34.6478288721 D 2 9.1770239974 14 18.3540479948 26 36.7080959897 Eb 3 9.7227182413 15 19.4454364826 27 38.8908729653 E 4 10.3008611535 16 20.6017223071 28 41.2034446141 F 5 10.9133822323 17 21.8267644646 29 43.6535289291 Gb 6 11.5623257097 18 23.1246514195 30 46.2493028390 G 7 12.2498573744 19 24.4997147489 31 48.9994294977 Ab 8 12.9782717994 20 25.9565435987 32 51.9130871975 A 9 13.7500000000 21 27.5000000000 33 55.0000000000 Bb 10 14.5676175474 22 29.1352350949 34 58.2704701898 B 11 15.4338531643 23 30.8677063285 35 61.7354126570 C4 36 65.4063913251 48 130.8127826503 60 261.6255653006 Db 37 69.2956577442 49 138.5913154884 61 277.1826309769 D 38 73.4161919794 50 146.8323839587 62 293.6647679174 Eb 39 77.7817459305 51 155.5634918610 63 311.1269837221 E 40 82.4068892282 52 164.8137784564 64 329.6275569129 F 41 87.3070578583 53 174.6141157165 65 349.2282314330 Gb 42 92.4986056779 54 184.9972113558 66 369.9944227116 G 43 97.9988589954 55 195.9977179909 67 391.9954359817 Ab 44 103.8261743950 56 207.6523487900 68 415.3046975799 A 45 110.0000000000 57 220.0000000000 69 440.0000000000 Bb 46 116.5409403795 58 233.0818807590 70 466.1637615181 B 47 123.4708253140 59 246.9416506281 71 493.8833012561 C7 72 523.2511306012 84 1046.5022612024 96 2093.0045224048 Db 73 554.3652619537 85 1108.7305239075 97 2217.4610478150 D 74 587.3295358348 86 1174.6590716696 98 2349.3181433393 Eb 75 622.2539674442 87 1244.5079348883 99 2489.0158697766 E 76 659.2551138257 88 1318.5102276515 100 2637.0204553030 F 77 698.4564628660 89 1396.9129257320 101 2793.8258514640 Gb 78 739.9888454233 90 1479.9776908465 102 2959.9553816931 G 79 783.9908719635 91 1567.9817439270 103 3135.9634878540 Ab 80 830.6093951599 92 1661.2187903198 104 3322.4375806396 A 81 880.0000000000 93 1760.0000000000 105 3520.0000000000 Bb 82 932.3275230362 94 1864.6550460724 106 3729.3100921447 B 83 987.7666025122 95 1975.5332050245 107 3951.0664100490 C10 108 4186.0090448096 120 8372.0180896192 Db 109 4434.9220956300 121 8869.8441912599 D 110 4698.6362866785 122 9397.2725733570 Eb 111 4978.0317395533 123 9956.0634791066 E 112 5274.0409106059 124 10548.0818212118 F 113 5587.6517029281 125 11175.3034058561 Gb 114 5919.9107633862 126 11839.8215267723 G 115 6271.9269757080 127 12543.8539514160 Ab 116 6644.8751612791 A 117 7040.0000000000 Bb 118 7458.6201842894 B 119 7902.1328200980]]>
Windows具有支持桌面应用程序中以及桌面应用程序中的诊断的API和服务。
评估执行引擎(Assessment Execution Engine) AXE API Win7 以上 AxeHosting.h 查不到更多信息了
调试和错误处理
硬件计数器分析
网络诊断框架
网络监控器
性能计数器
性能日志和警报
流程快照
流程状态API
系统事件通知服务
系统监控器
工具帮助库
Windows错误报告
Windows事件
Windows Performance Analyzer(WPA)
Windows Performance Toolkit(WPT)
Windows故障排除平台
Windows反恶意软件扫描接口(AMSI)是一种通用接口标准,可让您的应用程序和服务与计算机上存在的任何反恶意软件产品集成。
LSA身份验证
凭据管理
域凭证 域凭据的秘密部分(密码)受操作系统保护。只有使用LSA在进程中运行的代码才能读取和写入域凭据。应用程序仅限于编写域凭据
通用凭证 通用凭证可以由用户进程读取和写入
用户名格式
智能卡身份验证
网络提供程序
安全支持提供程序接口(SSPI)
Winlogon
GINA
[美国国防部定义的C2级安全性](https://docs.microsoft.com/windows/win32/secauthz/c2-level-security)
Access tokens
Security descriptors
每个进程都拥有用户登陆时创建的访问令牌。
访问令牌中包含安全标识符
安全描述符中包含用户的帐户以及用户所属的任何组帐户
ACL 访问控制列表
DACL
SACL 进程必须要有 SE_SECURITY_NAME特权
ACE Access Rights and Access Masks
ACE类型 | 描述 |
---|---|
Access-denied ACE | Used in a discretionary access control list (DACL) to deny access rights to a trustee. |
Access-allowed ACE | Used in a DACL to allow access rights to a trustee. |
System-audit ACE | Used in a system access control list (SACL) to generate an audit record when the trustee attempts to exercise the specified access rights. |
==文件目录特有==
ACE类型 | 描述 |
---|---|
Access-denied object ACE | Used in a DACL to deny a trustee access to a property or property set on the object, or to limit ACE inheritance to a specified type of child object. Uses the ACCESS_DENIED_OBJECT_ACE structure. |
Access-allowed object ACE | Used in a DACL to allow a trustee access to a property or property set on the object, or to limit ACE inheritance to a specified type of child object. Uses the ACCESS_ALLOWED_OBJECT_ACE structure. |
SSystem-audit object ACE | Used in a SACL to log a trustee’s attempts to access a property or property set on the object, or to limit ACE inheritance to a specified type of child object. Uses the SYSTEM_AUDIT_OBJECT_ACE structure. |
Trustees 委托人
用户账户、组账户、登录会话
Access Rights and Access Masks 访问权限和访问掩码
SID 安全描述符
Function | Description |
---|---|
AllocateAndInitializeSid | 用指定数量的子权限分配和初始化SID。 |
ConvertSidToStringSid | 将SID转换为适合于显示,存储或传输的字符串格式。 |
ConvertStringSidToSid | 将字符串格式的SID转换为有效的功能性SID。 |
CopySid | 将源SID复制到缓冲区。 |
EqualPrefixSid | 测试两个SID前缀值是否相等。SID前缀是除最后一个子权限值以外的整个SID。 |
EqualSid | 测试两个SID是否相等。它们必须完全匹配才能被视为相等。 |
FreeSid | 使用AllocateAndInitializeSid函数释放先前分配的SID 。 |
GetLengthSid | 检索SID的长度。 |
GetSidIdentifierAuthority | 检索指向SID标识符权限的指针。 |
GetSidLengthRequired | 检索存储具有指定数量的子权限的SID所需的缓冲区大小。 |
GetSidSubAuthority | 检索指向SID中指定的子权限的指针。 |
GetSidSubAuthorityCount | 检索SID中的子机构数。 |
InitialSid | 初始化SID结构。 |
IsValidSid | 通过验证修订号是否在已知范围内以及子授权机构的数量小于最大值来测试SID的有效性。 |
LookupAccountName | 检索与指定帐户名对应的SID。 |
LookupAccountSid | 检索与指定的SID对应的帐户名。 |
SID 结构
S - R - I - S S-1-5-32-544 本地Administrators组 1 修订级别 5 SECURITY_NT_AUTHORITY 32 SECURITY_BUILTIN_DOMAIN_RID 544 DOMAIN_ALIAS_RID_ADMINS
强制完整性控制
Windows Vista定义了四个完整性级别:低(SID: S-1-16-4096)、中(SID: S-1-16-8192)、高(SID: S-1-16-12288)、系统(SID: S-1-16-16384)。默认情况下,普通用户启动的进程将获得中完整性级别,而提升的进程则获得高完整性级别。通过引入完整性级别,强制完整性控制可以分类隔离程序,使得沙箱化潜在危险程序(如进行网络通信的程序)成为可能。低完整性进程所拥有的访问权限少于那些拥有更高完整性级别的进程。
permission 许可证、许可、允许
v.
adj.
it.
Access
U 道路
it.
Privilege 特权
adj.
n.
it.
Authorization 授权
Authentication 验证权限、身份验证、鉴定、认证
it.
rights 权力、正当的权力、公正
n.
token 代币、令牌、装点门面、证明、标记
As a token of goodwill, 为了证明我的好意
it.
certificate 毕业证书、证书、文凭
identifier 标识符
it.
https://docs.microsoft.com/windows/win32/secauthz/authorization-portal
SID_NAME_USE SID类型
1 | typedef enum _SID_NAME_USE { |
SECURITY_DESCRIPTOR
1 | typedef struct _SECURITY_DESCRIPTOR { |
ACL
1 | typedef struct _ACL { |
ACL_SIZE_INFORMATION
1 | typedef struct _ACL_SIZE_INFORMATION { |
LookupAccountName
1 | SID_NAME_USE snuType; |
AddAce AddAccessAllowedAceEx
1 |
|
SID
1 |
|
EXPLICIT_ACCESS
1 | typedef struct _EXPLICIT_ACCESS_W |
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git (需要翻墙)
设置环境变量 将depot_tools的路径添加到环境变量(建议放置第一条,在python环境变量之前)
禁止工具升级 ==设置环境变量== DEPOT_TOOLS_UPDATE=0 或者 ==删除.git目录==
工具库包含
GN是一个元构建系统,可为Ninja生成构建文件。
git clone https://gn.googlesource.com/gn
python build/gen.py
ninja -C out(环境要有ninja)
生成构建目录 gn gen out/windows_x86_debug
添加构建参数 gn args out/windows_x86_debug
1 | // gn args --list out/windows_x86_debug |
一般build目录下都有一些默认的配置 tool_chain
1 | # The location of the build configuration file. |
1 | ## 可执行程序 |
git clone git://github.com/ninja-build/ninja.git
cmake 编译或者https://github.com/ninja-build/ninja/releases下载binary
warning: A compatible version of re2c (>= 0.11.3) was not found; changes to src/*.in.cc will not affect your build.
wrote build.ninja.
安装re2c http://re2c.org/