-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
96 lines (96 loc) · 28 KB
/
index.html
File metadata and controls
96 lines (96 loc) · 28 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!doctype html><html lang=cn dir=auto><head><meta name=generator content="Hugo 0.143.1"><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name=robots content="index, follow"><title>MoonLab</title>
<meta name=keywords content="Blog,MoonLab,LingC"><meta name=description content="To the Moon"><meta name=author content="LingC"><link rel=canonical href=https://moonlab.top/><script id=MathJax-script async src=https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js></script><script>MathJax={tex:{displayMath:[["\\[","\\]"],["$$","$$"]],inlineMath:[["\\(","\\)"],["$","$"]]},loader:{load:["ui/safe"]}}</script><link crossorigin=anonymous href=/assets/css/stylesheet.1ff5a7b3bb4a96bf1747dfa25e8031167d4537d7ae4b78fac2b752886047a06e.css rel="preload stylesheet" as=style><link rel=icon href=/moon.svg type=image/svg+xml><link rel=icon type=image/png sizes=16x16 href=https://moonlab.top/favicon-16x16.png><link rel=icon type=image/png sizes=32x32 href=https://moonlab.top/favicon-32x32.png><link rel=apple-touch-icon href=https://moonlab.top/apple-touch-icon.png><link rel=mask-icon href=https://moonlab.top/safari-pinned-tab.svg><meta name=theme-color content="#2e2e33"><meta name=msapplication-TileColor content="#2e2e33"><link rel=alternate type=application/rss+xml href=https://moonlab.top/index.xml><link rel=alternate type=application/json href=https://moonlab.top/index.json><link rel=alternate hreflang=cn href=https://moonlab.top/><link rel=alternate hreflang=en href=https://moonlab.top/en/><noscript><style>#theme-toggle,.top-link{display:none}</style><style>@media(prefers-color-scheme:dark){:root{--theme:rgb(29, 30, 32);--entry:rgb(46, 46, 51);--primary:rgb(218, 218, 219);--secondary:rgb(155, 156, 157);--tertiary:rgb(65, 66, 68);--content:rgb(196, 196, 197);--code-block-bg:rgb(46, 46, 51);--code-bg:rgb(55, 56, 62);--border:rgb(51, 51, 51)}.list{background:var(--theme)}.list:not(.dark)::-webkit-scrollbar-track{background:0 0}.list:not(.dark)::-webkit-scrollbar-thumb{border-color:var(--theme)}}</style></noscript><meta property="og:title" content="MoonLab"><meta property="og:description" content="To the Moon"><meta property="og:type" content="website"><meta property="og:url" content="https://moonlab.top/"><meta property="og:site_name" content="MoonLab"><meta name=twitter:card content="summary"><meta name=twitter:title content="MoonLab"><meta name=twitter:description content="To the Moon"><script type=application/ld+json>{"@context":"https://schema.org","@type":"Organization","name":"MoonLab","url":"https://moonlab.top/","description":"To the Moon","thumbnailUrl":"https://moonlab.top/favicon.ico","sameAs":["https://github.com/HelloLingC","https://steamcommunity.com/id/lycoriszzz","mailto:me@moonlab.top"]}</script></head><body class=list id=top><script>localStorage.getItem("pref-theme")==="dark"?document.body.classList.add("dark"):localStorage.getItem("pref-theme")==="light"?document.body.classList.remove("dark"):window.matchMedia("(prefers-color-scheme: dark)").matches&&document.body.classList.add("dark")</script><header class=header><nav class=nav><div class=logo><a href=https://moonlab.top/ accesskey=h title="MoonLab (Alt + H)"><img src=/moon.svg alt aria-label=logo height=20>MoonLab</a><div class=logo-switches><button id=theme-toggle accesskey=t title="(Alt + T)"><svg id="moon" width="24" height="18" viewBox="0 0 24 24" fill="none" stroke="currentcolor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"/></svg><svg id="sun" width="24" height="18" viewBox="0 0 24 24" fill="none" stroke="currentcolor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/><line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/></svg></button><ul class=lang-switch><li>|</li><li><a href=https://moonlab.top/en/ title=English aria-label=English>En</a></li></ul></div></div><ul id=menu><li><a href=https://moonlab.top/archives/ title=归档><span>归档</span></a></li><li><a href=https://moonlab.top/search/ title=搜索><span>搜索</span></a></li><li><a href=https://moonlab.top/about/ title=关于><span>关于</span></a></li><li><a href=https://www.travellings.cn/go.html target=_blank title=开往><span>开往</span> <svg fill="none" shape-rendering="geometricPrecision" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" viewBox="0 0 24 24" height="12" width="12"><path d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"/><path d="M15 3h6v6"/><path d="M10 14 21 3"/></svg></a></li></ul></nav></header><div class=body-layout><div class=leftbar></div><main class=main><article class="first-entry home-info"><img class=avatar draggable=false src=/avatar.png alt="profile image" title height=150 width=150><div style=margin-left:16px><header class=entry-header><h1>Hello, LingC!</h1></header><div class=entry-content>Fish’s doom if not salted…</div><footer class=entry-footer><div class=social-icons><a href=https://github.com/HelloLingC target=_blank rel="noopener noreferrer me" title=Github><svg viewBox="0 0 24 24" fill="none" stroke="currentcolor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37.0 00-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44.0 0020 4.77 5.07 5.07.0 0019.91 1S18.73.65 16 2.48a13.38 13.38.0 00-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07.0 005 4.77 5.44 5.44.0 003.5 8.55c0 5.42 3.3 6.61 6.44 7A3.37 3.37.0 009 18.13V22"/></svg>
</a><a href=https://steamcommunity.com/id/lycoriszzz target=_blank rel="noopener noreferrer me" title=Steam><svg viewBox="0 0 24 24" fill="currentcolor" stroke="none"><path d="M-24.6 20.8c-1.4-.8-2.7-1.5-4.1-2.3-2.4-1.5-3.6-3.6-3.3-6.5.3-3 2.8-5.2 5.8-5.3h11c2.6.0 4.6 2.2 4.7 4.7.0 2.6-2 4.8-4.6 4.9h-2.8v.2c.2.2.5.3.7.5 1.2.7 2.4 1.3 3.6 2 2.5 1.5 3.7 4.5 2.9 7.2s-3.1 4.3-6.1 4.4h-10.6c-2.4.0-4.3-1.9-4.6-4.3-.3-2.3 1.2-4.5 3.5-5.1.6-.1 1.2-.1 1.7-.2h2.1c.1.0.1-.1.1-.2zm4.3-3.8c-.1.3-.2.3-.2.4v3.9c0 1.1-.1 1.2-1.2 1.2h-5.1c-.4.0-.9.0-1.3.1-1.6.4-2.5 1.9-2.4 3.6.2 1.6 1.6 2.9 3.3 2.9h10.5c2.1.0 3.8-1.2 4.5-3.1.7-1.8.2-4.1-1.5-5.3-2.1-1.3-4.3-2.4-6.6-3.7zm-1.7 3.4v-4c0-1.4.1-1.5 1.4-1.5h5.3c1.5.0 2.7-1 3.1-2.4.6-2.2-1-4.2-3.4-4.3h-10.1c-2.4.0-4.3 1.3-4.9 3.4-.6 2.1.4 4.4 2.5 5.5 1.7 1 3.5 1.9 5.2 2.9.4.2.6.3.9.4z"/><path d="M53.3 6.9c-.2-1-1-1.7-1.9-2-1.7-.4-8.6-.4-8.6-.4s-6.9.0-8.6.5c-1 .3-1.7 1-1.9 2-.3 1.7-.5 3.5-.5 5.3s.1 3.6.5 5.3c.3.9 1 1.7 1.9 1.9 1.7.5 8.6.5 8.6.5s6.9.0 8.6-.5c1-.3 1.7-1 1.9-2 .3-1.7.5-3.5.5-5.3s-.1-3.6-.5-5.3z"/><path d="m40.6 15.5 5.7-3.3-5.7-3.3z"/><path d="M72.4-9.9c5.5.0 10 4 10 8.9.0 1.8-.8 3.8-2.1 5.4-.9 1-1.5 2.3-1.6 3.7.0-.1-.1-.1-.2-.2-.4-.4-1.1-.7-1.7-.7-.3.0-.5.0-.8.1-1.2.5-2.5.7-3.6.7-5.5.0-10-4-10-8.9s4.5-9 10-9m0-2c-6.6.0-12 4.9-12 10.9s5.4 11 12 11c1.4.0 2.8-.2 4.2-.7h.1c.1.0.2.0.3.1 1 1.3 2.5 2.3 4.2 2.7l.2-.1v-.3c-.7-.9-1-1.9-1-3s.4-2.1 1.2-2.9c1.5-1.8 2.6-4.2 2.6-6.7.1-6.1-5.3-11-11.8-11z"/><path d="M72.3-6.5c.1.0.3.1.3.2l1.2 3.4 3.7.1c.1.0.3.1.3.2s0 .3-.1.4l-3 2.2 1.1 3.5c0 .1.0.3-.1.4h-.4l-3-2.1-3 2.1h-.4c-.1-.1-.2-.2-.1-.4L69.9.0l-3-2.2c-.1-.1-.2-.2-.1-.4.0-.1.2-.2.3-.2l3.7-.1L72-6.3c0-.1.2-.2.3-.2zM46.8-20.8c2 0 4 .6 5.6 1.6-.5-.1-1.1-.2-1.6-.2-3.2.0-5.8 2.5-6 5.6l-2.2 3.2c-.5.1-.9.2-1.4.4l-4.7-1.9c.8-5 5.2-8.7 10.3-8.7m9.9 7.2c.3 1 .5 2.1.5 3.3C57.2-4.5 52.5.2 46.7.2c-1.8.0-3.6-.5-5.1-1.3.5.2 1 .2 1.5.2 2.5.0 4.5-1.9 4.8-4.3L51-7.4c3.1-.2 5.6-2.8 5.6-6 .1-.1.1-.1.1-.2M38.3-4.2l.3.2c.1.2.2.5.3.7l-.6-.9m8.5-18.1c-6.3.0-11.5 4.9-12 11l6.4 2.7c.5-.4 1.2-.6 1.9-.6h.2l2.9-4.1v-.1c0-2.5 2-4.5 4.5-4.5s4.5 2 4.5 4.5-2 4.5-4.5 4.5h-.1L46.5-6v.2c0 1.9-1.5 3.4-3.4 3.4-1.6.0-3-1.2-3.3-2.7L35.2-7c1.4 5 6 8.7 11.5 8.7 6.6.0 12-5.4 12-12s-5.3-12-11.9-12z"/><path d="M42.6-4.6 41.5-5c.2.4.5.7 1 .9 1 .4 2.1-.1 2.5-1 .2-.5.2-1 0-1.4-.2-.5-.6-.8-1-1-.5-.2-1-.2-1.4.0l1.1.5c.7.3 1 1.1.7 1.8-.3.6-1.1.9-1.8.6zm8.1-11.5c-1.5.0-2.7 1.2-2.7 2.7s1.2 2.7 2.7 2.7 2.7-1.2 2.7-2.7-1.2-2.7-2.7-2.7zm0 4.7c-1.1.0-2-.9-2-2s.9-2 2-2 2 .9 2 2c.1 1.1-.9 2-2 2zM12 0C5.4.0.0 5.4.0 12s5.4 12 12 12 12-5.4 12-12S18.6.0 12 0zm0 22c-4.3.0-8-2.7-9.4-6.5L6.2 17c.3 1.3 1.5 2.4 2.9 2.4 1.6.0 2.9-1.3 2.9-2.9v-.1l3.5-2.5h.1c2.1.0 3.9-1.8 3.9-3.9s-1.8-3.9-3.9-3.9c-2.2.0-3.9 1.8-3.9 3.9v.1l-2.5 3.6H9c-.6.0-1.2.2-1.7.5L2 11.7C2.2 6.3 6.6 2 12 2c5.5.0 10 4.5 10 10s-4.5 10-10 10zm-2.4-7.1-1.3-.5c.5-.2 1.1-.2 1.6.0s1 .7 1.2 1.2.2 1.1.0 1.7c-.5 1.1-1.8 1.7-2.9 1.2-.5-.2-.9-.6-1.1-1.1l1.3.5c.2.0.4.1.6.1.6.0 1.2-.4 1.5-1 .4-.9.0-1.8-.9-2.1zM13 9.8c0-1.5 1.2-2.6 2.6-2.6 1.5.0 2.6 1.2 2.6 2.6.0 1.5-1.2 2.6-2.6 2.6S13 11.2 13 9.8z"/><path d="M13.7 9.8c0-1.1.9-2 2-2s2 .9 2 2-.9 2-2 2c-1.1-.1-2-.9-2-2z"/></svg>
</a><a href=mailto:me@moonlab.top target=_blank rel="noopener noreferrer me" title=Email><svg viewBox="0 0 24 21" fill="none" stroke="currentcolor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 4h16c1.1.0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1.0-2-.9-2-2V6c0-1.1.9-2 2-2z"/><polyline points="22,6 12,13 2,6"/></svg></a></div></footer></article><article class=post-entry><header class=entry-header><h2 class=entry-hint-parent>VSCode + OpenOCD 远程调试开发STM32</h2></header><div class=entry-content><p>[PC] --Wi-Fi--> [树莓派5] --USB--> [DAPLink] --SWD--> [STM32目标板] 树莓派配置 测试Daplink USB连接状态
lsusb 必要的包 openocd gdb-multiarch git make sudo apt install openocd gdb-multiarch git make OpenOCD openocd -f interface/cmsis-dap.cfg -f target/stm32f1x.cfg 默认情况下,OpenOCD启动的GDB服务器(3333端口)只监听本地回环地址(127.0.0.1)
我们需要让OpenOCD监听所有网络接口(0.0.0.0)
nano ~/remote_daplink.cfg # 指定使用CMSIS-DAP接口 adapter driver cmsis-dap # 使用SWD协议,STM32F1支持SWD transport select swd # 可选:设置适配器速度,如果连接不稳定可以降低速度(单位kHz) adapter speed 1000 # 指定STM32F1x的目标配置文件 source [find target/stm32f1x.cfg] bindto 0.0.0.0 gdb_port 3333 telnet_port 4444 tcl_port 6666 # 可选:如果你希望OpenOCD在后台运行(作为守护进程 # daemon_startup attach sudo openocd -f ~/remote_daplink.cfg Tips: -d:输出调试信息
...</p></div><footer class=entry-footer><span title='2025-11-01 14:20:04 +0800 +0800'>November 1, 2025</span> · LingC</footer><a class=entry-link aria-label="post link to VSCode + OpenOCD 远程调试开发STM32" href=https://moonlab.top/posts/2025/daplink-remote-debug/></a></article><article class=post-entry><header class=entry-header><h2 class=entry-hint-parent>Clangd + VSCode使用方法</h2></header><div class=entry-content><p>clangd 是基于 Clang 编译器的 C/C++/Objective-C 语言服务器。
它提供类似 IDE 的功能,例如代码补全、跳转导航、重构和诊断,并可在支持 LSP(语言服务器协议)的编辑器中使用,如 VSCode、Neovim、Sublime 等。
代码补全(Code completion)
在你输入代码时,自动建议变量、函数和类型。
跳转到定义 & 查找引用(Go-to-definition & Find references)
一键跳转到符号的定义,或查找它在何处被使用。
诊断与警告(Diagnostics & warnings)
不用手动编译,编辑器中就能显示编译错误和警告。
重构 & 代码操作(Refactoring & code actions)
支持重命名符号、生成函数框架、自动修复 include 等。
请确保在项目根目录下有一个 compile_commands.json 文件。
👉 参考文档:JSON Compilation Database
CMake(2.8.5 及以上版本)支持在使用 Unix Makefile 构建时,通过设置 CMAKE_EXPORT_COMPILE_COMMANDS 选项来生成这个编译数据库。
但是也可以用Bear来生成。
brew install bear bear -- make clean all 但是我在Mac平台下使用arm-none-eabi-gcc来进行交叉编译的时候,bear生成的compile_commands.json里只有[]。
我懒得找解决方法,就直接用compiledb最后生成了compile_commands.json:
在VSCode中Ctrl + Shift + P打开 Preferences: Open Settings(JSON)编辑settings.json
或手动去寻找:
...</p></div><footer class=entry-footer><span title='2025-10-23 00:36:09 +0800 +0800'>October 23, 2025</span> · LingC</footer><a class=entry-link aria-label="post link to Clangd + VSCode使用方法" href=https://moonlab.top/posts/2025/clangd/></a></article><article class=post-entry><header class=entry-header><h2 class=entry-hint-parent>Keil5 编译错误 error: call to undeclared function '__enable_irq'</h2></header><div class=entry-content><p>stm32f1xx_hal_i2c.c 中 __enable_irq 和 disable_irq 函数出现了报错:
error: call to undeclared function '__enable_irq'; ISO C99 and later do not support implicit of function declarations 在 core_cm3.h -> cmsis_compiler.h -> cmsis_armclang.h (ARM Compiler 6) 或 cmsis_armcc.h (AC5) 中对这两个方法没有定义,只有一段注释:
__enable_irq 和 disable_irq 控制的是PRIMASK寄存器值。
是一种 intrinsic 函数,编译器会自动识别并替换为相关的指令,它们其实是编译器的一部分,实际的定义位于Keil的 arm_compat.h 中。
/* * Arm Compiler 6 (armclang) */ #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #include "cmsis_armclang.h" 在其中,这个头文件 arm_compat.h 本该是不存在的:
#include <arm_compat.h> 在.\Drivers\CMSIS\Include 中多了一个arm_compat.h文件,这会导致覆盖编译器的头文件,所以会出现一系列错误。
...</p></div><footer class=entry-footer><span title='2025-09-06 21:25:30 +0800 +0800'>September 6, 2025</span> · LingC</footer><a class=entry-link aria-label="post link to Keil5 编译错误 error: call to undeclared function '__enable_irq'" href=https://moonlab.top/posts/2025/keil-i2c-error/></a></article><article class=post-entry><header class=entry-header><h2 class=entry-hint-parent>BTSNOOP is FUN!</h2></header><div class=entry-content><p>手机 HCI 日志记录 在VIVO手机中的开发者选项,启用蓝牙 HCI 信息手机日志。
用USB连接电脑后,将 USB连接方式 调整为传输文件。
adb bugreport vivo_btsnoop 会在 /data/user_de/0/com.android.shell/files/ 下生成日志,并自动拉取到电脑上。
在 bugreport.zip 下的 \FS\data\misc\bluetooth\logs 中能找到 HCI log:
Knowledge Base UUID UUID(Universally Unique Identifier)是一个 128位(16字节) 的唯一标识符,用于标识蓝牙协议中的各种组件 Services Characteristics Descriptors 的类型和功能。
Service Service 是蓝牙设备提供的 功能集合,每个 Service 包含一个或多个 Characteristic
Service 也分为 Primary Service 和 Secondary Service
Characteristic Characteristic 是 Service 中的 具体数据点,用于 读取、写入、通知 数据。
每个 Characteristic 包含:
Value:存储的数据(如温度、心率等)。 Properties:定义操作权限(read、write、notify 等)。 Descriptors:额外配置(如通知开关)。 抓包 我已经知道这是一个蓝牙低功耗(BLE)设备,只需找到Attribute Protocol通信:
...</p></div><footer class=entry-footer><span title='2025-08-01 22:40:44 +0800 +0800'>August 1, 2025</span> · LingC</footer><a class=entry-link aria-label="post link to BTSNOOP is FUN!" href=https://moonlab.top/posts/2025/btsnoop/></a></article><article class=post-entry><header class=entry-header><h2 class=entry-hint-parent>算法 - 前缀和</h2></header><div class=entry-content><p>在需要频繁地求数组中区间的和的情景下,前缀和数组十分有用。花费 $O(n)$ 的时间生成前缀和,之后只需要 $O(1)$ 的时间计算区间和。
定义一个数组a = [1, 2, 3, 4, 5],它的前缀和数组:
prefix[0] = 1 prefix[1] = 1 + 2 = 3 prefix[2] = 1 + 2 + 3 = 6 prefix[3] = 1 + 2 + 3 + 4 = 10 prefix[4] = 1 + 2 + 3 + 4 + 5 = 15 要计算 $[i,j]$ 区间的和,可以用 prefix[j] - prefix[i-1] 算出,其中 i = 0 下溢时直接取 prefix[j]。
vector<int> prefix(n); int sum = 0; for(int i = 0; i < n; i++) { sum += i; prefix[i] = sum; } C++的numeric库提供了一个方便的函数partial_sum可以快速计算前缀和。
...</p></div><footer class=entry-footer><span title='2025-05-04 02:23:47 +0800 +0800'>May 4, 2025</span> · LingC</footer><a class=entry-link aria-label="post link to 算法 - 前缀和" href=https://moonlab.top/posts/2025/alg-prefix-array/></a></article><article class=post-entry><header class=entry-header><h2 class=entry-hint-parent>2025蓝桥杯赛后总结</h2></header><div class=entry-content><p>这次省赛,实际上我并无准备,因为我一如既往地对算法没有什么兴趣。
竞赛一共八道题,A和B题是填空题,后六道题都是程序设计。前五题都做了,第六题暴力应该只拿了部分分,后两题就没时间写了。
在赛场上当时看到C++编译器是2014年发布的gcc 4.7.4,用的是C++98标准。但蓝桥杯的云端是可以运行C++11以上的标准的代码的。
本地做题环境的编译器低版本,导致许多C++函数用不了。比如 to_string()函数用不了。前两题最快速的做饭需要将数转到字符串类型,但是我只知道c++中有一个方便的 to_string() 函数,还好当时我看到赛场机子中有Pycharm,所以我就用python计算了前两道填空题。
这个向下兼容的过程,消耗了我大量时间。
最致命的是,有一道题我需要声明一个迭代器,但是我不知道迭代器的类型名,一般来说都是用auto自动推导的,但auto只在C++11标准以上才有,导致这道题的代码我在本地环境无法测试。明明代码是正确的,但本地的低版本编译器却认为我的代码是错误的。这种割裂感很少有。
而现在看来这道题也依旧做对了。
// C++98 std::vector<int> vec; std::vector<int>::iterator it = vec.begin(); // C++ 11 auto it = vec.begin(); // 自动推导为 std::vector<int>::iterator 与当时赛场的老师沟通,得知组委会只要求提供5.11版本的dev c++,而他们似乎只更新了代码编辑器版本,但一般来说dev c++是捆绑了一个编译器的,但不知为何内置的编译器却十分古典,感觉有点意思。
比赛完后,我查找了在 C++98 的字符串类型转换方法:
// for C++98/03 standard string old_int_to_string(int v) { ostringstream oss; oss << v; return oss.str(); } string old_double_to_string(double v) { ostringstream oss; oss << fixed << setprecision(6) << v; return oss.str(); } string old_c_style_to_string(int v) { char buffer[32]; // make sure buffer is suffcient sprintf(buffer, "%d", v); return string(buffer); } 事实上,生活在草台班子里的我们不必认真太多。
...</p></div><footer class=entry-footer><span title='2025-05-01 16:11:27 +0800 +0800'>May 1, 2025</span> · LingC</footer><a class=entry-link aria-label="post link to 2025蓝桥杯赛后总结" href=https://moonlab.top/posts/2025/lanqiao-aftermatch/></a></article><article class=post-entry><header class=entry-header><h2 class=entry-hint-parent>三星ZFold 3改造</h2></header><div class=entry-content><p>Samsung ZFold 3 BootLoader Unlock 打开 OEM Unlock
Root Get the Firmware 获取系统固件可以通过网络查找,也可以借助官方工具进行下载。下面将借助S换机助手将手机更新到最新版系统来获取固件。
解锁BL后,在手机中进行系统更新会提示不信任设备,只能借助S换机助手来更新系统。
连接后,换机助手会下载固件到安装路径下的Binary文件夹中,在手机Download完成后会自动删除下载的固件。
更新完成后,手机的系统版本是2025/6/29发布的大陆版F9260ZCSCKYF3
将AP中的boot.img.lz4压缩为tar格式
https://github.com/fei-ke/Magisk/releases
使用Magisk对镜像进行修补
adb reboot download
使用Odin刷入镜像</p></div><footer class=entry-footer><span title='2025-05-01 16:11:27 +0800 +0800'>May 1, 2025</span> · LingC</footer><a class=entry-link aria-label="post link to 三星ZFold 3改造" href=https://moonlab.top/posts/2025/samsung-zfold3/></a></article><article class=post-entry><header class=entry-header><h2 class=entry-hint-parent>JavaScript 逆向 Steam 登录二维码</h2></header><div class=entry-content><p>众所周知,steam里骗子猖狂。以下页面是骗子私信发给我的一个仿冒的steam钓鱼网站。
如果点击 接受礼物 就会跳转至虚假的steam登录界面。
如果毫无防备,通过手机steam客户端扫描右边的二维码进行登录,steam会进行登录异常的警告,一般来说要通过这一步还是很麻烦的。如果强行继续,那么steam账号除了会被劫持api key以外,大概率还会被洗库存,比如一些便宜的卡片和库存里的小件都会被卖出,而不会触发steam手机令牌的验证。
那么骗子是如何制作这些钓鱼网站的?steam对于自身系统的保护究竟做的怎么样?
这些都绕不开对于steam的逆向分析。
开始逆向 抓包观察了一会steam登录界面后,就已经捋清了整个登录站点的逻辑。
在最开始会连接/BeginAuthStatusViaQRCode 获取登录二维码,之后每隔一段时间(5s)就会请求 PollAuthSessionStatus/v1 以更新会话状态,如果当前页面的二维码已经过期,则会刷新。
如果先点击登录按钮,会请求/GetPasswordRSAPublicKey/v1,之后是 /BeginAuthSessionStatusViaCredentials。
可以很明显的看到用的是 protobuf 协议。
查看这个网络请求的来源:
继续追踪这个API的来源。在js文件顶部可以看到这是用webpack打包的:
找到来自Send的方法调用比较可疑:
这里的 r 是一个对象,查看一下它的构造方法:
已经能看到proto的结构了。
构建出用于请求GetPasswordRSAPublicKey/v1的proto:
syntax = "proto3"; package steam; option go_package = "proto/steam" message GetPasswordRSAPublicKey_Request { string account_name = 1; } message GetPasswordRSAPublicKey_Response { string public_key_mod = 1; string public_key_exp = 2; uint64 timestamp = 3; } 编译proto:
$ protoc --go_out=. --go-grpc_out=. steam.proto 安装golang的protobuf包:
...</p></div><footer class=entry-footer><span title='2025-02-05 18:22:04 +0800 +0800'>February 5, 2025</span> · LingC</footer><a class=entry-link aria-label="post link to JavaScript 逆向 Steam 登录二维码" href=https://moonlab.top/posts/2025/steam/></a></article><article class=post-entry><header class=entry-header><h2 class=entry-hint-parent>快速求解平方根倒数算法</h2></header><div class=entry-content><p>本文介绍了一种快速计算平方根倒数的算法,该算法源于上世纪90年代。文章首先解释了浮点数在计算机中的存储方式,特别是float32格式的结构,包括符号位、指数位和尾数位。接着,介绍了牛顿迭代法的基本原理及其在求解平方根倒数中的应用。通过对浮点数的对数变换,推导出与平方根倒数相关的公式,并解释了代码中使用的神秘常数 0x5f3759df 的来源,最后提到切比雪夫最佳逼近的概念,以优化计算结果。</p></div><footer class=entry-footer><span title='2025-02-04 21:35:38 +0800 +0800'>February 4, 2025</span> · LingC</footer><a class=entry-link aria-label="post link to 快速求解平方根倒数算法" href=https://moonlab.top/posts/2025/alg-graphics-1/></a></article><article class=post-entry><header class=entry-header><h2 class=entry-hint-parent>Protobuf</h2></header><div class=entry-content><p>安装 protobuf 假设环境下已有protoc (protocal buffers compiler)。
对于 Go 语言,安装相应的可执行文件:
go install google.golang.org/grpc/cmd/protoc-gen-go@latest go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest 在Windows中,执行完安装命令后在C:\Users\user\go\bin路径下会有proctoc-gen-go.exe和protoc-gen-go-grpc.exe。
安装完Go插件后,我们希望protoc生成Go语言的代码,需要为 .proto 文件加一行以指定生成的Go包名:
syntax = "proto3"; package com.example.pkg option go_package = "example/gopkg" 如果需要使用 grpc 服务,安装包:
go get google.golang.org/grpc 之后便可启动一个 gRPC 服务器:
gRPC gateway 为 gRPC 服务生成面向 RestFul API 的网关
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@latest go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@latest syntax = "proto3"; package com.example.pkg import "google/api/annotations.proto"; option go_package = "example/gopkg service AuthService { rpc Login(LRequest) returns (LResponse) { option (google.api.http) = { post: "/v1/login" body: "*" }; } message LRequest { string field = 1; } message LResponse { string field = 1; } 之后便可以生成grpc gateway的代码了:
...</p></div><footer class=entry-footer><span title='2025-01-24 03:33:27 +0800 +0800'>January 24, 2025</span> · LingC</footer><a class=entry-link aria-label="post link to Protobuf" href=https://moonlab.top/posts/2025/protobuf3/></a></article><footer class=page-footer><nav class=pagination><a class=next href=https://moonlab.top/page/2/>下一页 »</a></nav></footer></main><aside class=rightbar><div class=rightbar-categories><h3>分类</h3><ul class=rightbar-categories-first-list><li><a href=https://moonlab.top/categories/programming/>Programming</a> (17)<ul class=rightbar-categories-sec-list><li><a href=/tags/embeded>Embeded</a></li><li><a href=/tags/golang>golang</a></li><li><a href=/tags/linux>Linux</a></li><li><a href=/tags/android>Android</a></li></ul></li><li><a href=https://moonlab.top/categories/reverse/>Reverse</a> (1)<ul class=rightbar-categories-sec-list><li><a href=/tags/javascript>JavaScript</a></li></ul></li><li><a href=https://moonlab.top/categories/%E5%85%B6%E4%BB%96/>其他</a> (5)<ul class=rightbar-categories-sec-list><li><a href=/tags/blog>blog</a></li></ul></li><li><a href=https://moonlab.top/categories/%E7%AE%97%E6%B3%95/>算法</a> (4)<ul class=rightbar-categories-sec-list></ul></li></ul></div></aside></div><footer class=footer><img id=mooncounter-img style="margin:0 auto;margin-bottom:6px"></img>
<script src="//counter.moonlab.top/img?name=https://moonlab.top/"></script><span>© 2025 <a href=https://moonlab.top/>MoonLab</a></span> ·
<span>Powered by
<a href=https://gohugo.io/ rel="noopener noreferrer" target=_blank>Hugo</a> &
<a href=https://github.com/adityatelange/hugo-PaperMod/ rel=noopener target=_blank>PaperMod</a>
</span><a href=https://www.travellings.cn/go.html rel=noopener target=_blank><img style=height:27px alt=travelling src=https://www.travellings.cn/assets/logo.svg></a></footer><a href=#top aria-label="go to top" title="Go to Top (Alt + G)" class=top-link id=top-link accesskey=g><svg viewBox="0 0 12 6" fill="currentcolor"><path d="M12 6H0l6-6z"/></svg>
</a><script>let menu=document.getElementById("menu");menu&&(menu.scrollLeft=localStorage.getItem("menu-scroll-position"),menu.onscroll=function(){localStorage.setItem("menu-scroll-position",menu.scrollLeft)}),document.querySelectorAll('a[href^="#"]').forEach(e=>{e.addEventListener("click",function(e){e.preventDefault();var t=this.getAttribute("href").substr(1);window.matchMedia("(prefers-reduced-motion: reduce)").matches?document.querySelector(`[id='${decodeURIComponent(t)}']`).scrollIntoView():document.querySelector(`[id='${decodeURIComponent(t)}']`).scrollIntoView({behavior:"smooth"}),t==="top"?history.replaceState(null,null," "):history.pushState(null,null,`#${t}`)})})</script><script>var mybutton=document.getElementById("top-link");window.onscroll=function(){document.body.scrollTop>800||document.documentElement.scrollTop>800?(mybutton.style.visibility="visible",mybutton.style.opacity="1"):(mybutton.style.visibility="hidden",mybutton.style.opacity="0")}</script><script>document.getElementById("theme-toggle").addEventListener("click",()=>{document.body.className.includes("dark")?(document.body.classList.remove("dark"),localStorage.setItem("pref-theme","light")):(document.body.classList.add("dark"),localStorage.setItem("pref-theme","dark"))})</script></body></html>