经典文章-API Hook Revealed - 2

027-监控运维:告警、灰度与回滚机制 本文分享了监控运维中告警、灰度与回滚的实战经验。强调告警需分层设计,避免误报漏报,重点监控“任务未执行”等隐蔽问题;灰度发布应按比例逐步放量,并确保新旧版本数据可对账;回滚必须提前配置,实现一键切换,支持自动回滚兜底。三者形成闭环,关键在于“未雨绸缪”——在无故障时就建立可靠机制,才能真正实现系统稳定。 阅读详情

Figuring out when to inject the hook DLL

That section reveals some challenges that are faced by developers when the selected injection mechanism is not part of the operating system's functionality. For example, performing the injection is not your concern when you use built-in Windows Hooks in order to implant a DLL. It is an OS's responsibility to force each of those running processes that meet the requirements for this particular hook, to load the DLL [18]. In fact Windows keeps track of all newly launched processes and forces them to load the hook DLL. Managing injection through registry is quite similar to Windows Hooks. The biggest advantage of all those "built-in" methods is that they come as part of the OS.

Unlike the discussed above implanting techniques, to inject by CreateRemoteThread() requires maintenance of all currently running processes. If the injecting is made not on time, this can cause the Hook System to miss some of the calls it claims as intercepted. It is crucial that the Hook Server application implements a smart mechanism for receiving notifications each time when a new process starts or shuts down. One of the suggested methods in this case, is to intercept CreateProcess() API family functions and monitor all their invocations. Thus when an user supplied function is called, it can call the original CreateProcess() with dwCreationFlags OR -ed with CREATE_SUSPENDED flag. This means that the primary thread of the targeted application will be in suspended state, and the Hook Server will have the opportunity to inject the DLL by hand-coded machine instructions and resume the application using ResumeThread() API. For more details you might refer to [2] "Injecting Code with CreateProcess()" .

The second method of detecting process execution, is based on implementing a simple device driver. It offers the greatest flexibility and deserves even more attention. Windows NT/2K provides a special function PsSetCreateProcessNotifyRoutine() exported by NTOSKRNL. This function allows adding a callback function, that is called whenever a process is created or deleted. For more details see [11] and [15] from the reference section.

Enumerating processes and modules

Sometimes we would prefer to use injecting of the DLL by CreateRemoteThread() API, especially when the system runs under NT/2K. In this case when the Hook Server is started it must enumerate all active processes and inject the DLL into their address spaces. Windows 9x and Windows 2K provide a built-in implementation (i.e. implemented by Kernel32.dll) of Tool Help Library. On the other hand Windows NT uses for the same purpose PSAPI library. We need a way to allow the Hook Server to run and then to detect dynamically which process "helper" is available. Thus the system can determine which the supported library is, and accordingly to use the appropriate APIs.

I will present an object-oriented architecture that implements a simple framework for retrieving processes and modules under NT/2K and 9x [16]. The design of my classes allows extending the framework according to your specific needs. The implementation itself is pretty straightforward.

CTaskManager implements the system's processor. It is responsible for creating an instance of a specific library handler (i.e. CPsapiHandler or CToolhelpHandler ) that is able to employ the correct process information provider library (i.e. PSAPI or ToolHelp32 respectively). CTaskManager is in charge of creating and marinating a container object that keeps a list with all currently active processes. After instantiating of the CTaskManager object the application calls Populate() method. It forces enumerating of all processes and DLL libraries and storing them into a hierarchy kept by CTaskManager 's member m_pProcesses .

Following UML diagram shows the class relationships of this subsystem:

Figure 5

It is important to highlight the fact that NT's Kernel32.dll doesn't implement any of the ToolHelp32 functions. Therefore we must link them explicitly, using runtime dynamic linking. If we use static linking the code will fail to load on NT, regardless whether or not the application has attempted to execute any of those functions. For more details see my article "Single interface for enumerating processes and modules under NT and Win9x/2K." .

Requirements of the Hook Tool System

Now that I've made a brief introduction to the various concepts of the hooking process it's time to determine the basic requirements and explore the design of a particular hooking system. These are some of the issues addressed by the Hook Tool System:

  • Provide a user-level hooking system for spying any Win32 API functions imported by name
  • Provide the abilities to inject hook driver into all running processes by Windows hooks as well as CreateRemoteThread() API. The framework should offer an ability to set this up by an INI file
  • Employ an interception mechanism based on the altering Import Address Table
  • Present an object-oriented reusable and extensible layered architecture
  • Offer an efficient and scalable mechanism for hooking API functions
  • Meet performance requirements
  • Provide a reliable communication mechanism for transferring data between the driver and the server
  • Implement custom supplied versions of TextOutA/W() and ExitProcess() API functions
  • Log events to a file
  • The system is implemented for x86 machines running Windows 9x, Me, NT or Windows 2K operating system

Design and implementation

This part of the article discusses the key components of the framework and how do they interact each other. This outfit is capable to capture any kind of WINAPI imported by name functions.

Before I outline the system's design, I would like to focus your attention on several methods for injecting and hooking.

First and foremost, it is necessary to select an implanting method that will meet the requirements for injecting the DLL driver into all processes. So I designed an abstract approach with two injecting techniques, each of them applied accordingly to the settings in the INI file and the type of the operating system (i.e. NT/2K or 9x). They are - System-wide Windows Hooks and CreateRemoteThread() method. The sample framework offers the ability to inject the DLL on NT/2K by Windows Hooks as well as to implant by CreateRemoteThread() means. This can be determined by an option in the INI file that holds all settings of the system.

Another crucial moment is the choice of the hooking mechanism. Not surprisingly, I decided to apply altering IAT as an extremely robust method for Win32 API spying.

To achieve desired goals I designed a simple framework composed of the following components and files:

  • TestApp.exe - a simple Win32 test application that just outputs a text using TextOut() API. The purpose of this app is to show how it gets hooked up.
  • HookSrv.exe - control program
  • HookTool .DLL - spy library implemented as Win32 DLL
  • HookTool.ini - a configuration file
  • NTProcDrv.sys - a tiny Windows NT/2K kernel-mode driver for monitoring process creation and termination. This component is optional and addresses the problem with detection of process execution under NT based systems only.

HookSrv is a simple control program. Its main role is to load the HookTool.DLL and then to activate the spying engine. After loading the DLL, the Hook Server calls InstallHook() function and passes a handle to a hidden windows where the DLL should post all messages to.

HookTool.DLL is the hook driver and the heart of presented spying system. It implements the actual interceptor and provides three user supplied functions TextOutA/W() and ExitProcess() functions.

Although the article emphasizes on Windows internals and there is no need for it to be object-oriented, I decided to encapsulate related activities in reusable C++ classes. This approach provides more flexibility and enables the system to be extended. It also benefits developers with the ability to use individual classes outside this project.

Following UML class diagram illustrates the relationships between set of classes used in HookTool.DLL's implementation.

Figure 6

In this section of the article I would like to draw your attention to the class design of the HookTool.DLL. Assigning responsibilities to the classes is an important part of the development process. Each of the presented classes wraps up a specific functionality and represents a particular logical entity.

CModuleScope is the main doorway of the system. It is implemented using "Singleton" pattern and works in a thread-safe manner. Its constructor accepts 3 pointers to the data declared in the shared segment, that will be used by all processes. By this means the values of those system-wide variables can be maintained very easily inside the class, keeping the rule for encapsulation.

When an application loads the HookTool library, the DLL creates one instance of CModuleScope on receiving DLL_PROCESS_ATTACH notification. This step just initializes the only instance of CModuleScope . An important piece of the CModuleScope object construction is the creation of an appropriate injector object. The decision which injector to use will be made after parsing the HookTool.ini file and determining the value of UseWindowsHook parameter under [Scope] section. In case that the system is running under Windows 9x, the value of this parameter won't be examined by the system, because Window 9x doesn't support injecting by remote threads.

After instantiating of the main processor object, a call to ManageModuleEnlistment() method will be made. Here is a simplified version of its implementation:

Collapse Copy Code
//
 Called on DLL_PROCESS_ATTACH DLL notification
BOOL CModuleScope::ManageModuleEnlistment()
{
BOOL bResult = FALSE;
// Check if it is the hook server
if (FALSE == *m_pbHookInstalled)
{
// Set the flag, thus we will know that the server has been installed
*m_pbHookInstalled = TRUE;
// and return success error code
bResult = TRUE;
}
// and any other process should be examined whether it should be
// hooked up by the DLL
else
{
bResult = m_pInjector-> IsProcessForHooking(m_szProcessName);
if (bResult)
InitializeHookManagement();
}
return bResult;
}

The implementation of the method ManageModuleEnlistment() is straightforward and examines whether the call has been made by the Hook Server, inspecting the value m_pbHookInstalled points to. If an invocation has been initiated by the Hook Server, it just sets up indirectly the flag sg_bHookInstalled to TRUE. It tells that the Hook Server has been started.

The next action taken by the Hook Server is to activate the engine through a single call to InstallHook() DLL exported function. Actually its call is delegated to a method of CModuleScope - InstallHookMethod() . The main purpose of this function is to force targeted for hooking processes to load or unload the HookTool.DLL.

Collapse Copy Code
//
 Activate/Deactivate hooking
engine BOOL CModuleScope::InstallHookMethod(BOOL bActivate, HWND hWndServer)
{
BOOL bResult;
if (bActivate)
{
*m_phwndServer = hWndServer;
bResult = m_pInjector-> InjectModuleIntoAllProcesses();
}
else
{
m_pInjector-> EjectModuleFromAllProcesses();
*m_phwndServer = NULL;
bResult = TRUE;
}
return bResult;
}

HookTool.DLL provides two mechanisms for self injecting into the address space of an external process - one that uses Windows Hooks and another that employs injecting of DLL by CreateRemoteThread() API. The architecture of the system defines an abstract class CInjector that exposes pure virtual functions for injecting and ejecting DLL. The classes CWinHookInjector and CRemThreadInjector inherit from the same base - CInjector class. However they provide different realization of the pure virtual methods InjectModuleIntoAllProcesses() and EjectModuleFromAllProcesses() , defined in CInjector interface.

CWinHookInjector class implements Windows Hooks injecting mechanism. It installs a filter function by the following call

Collapse Copy Code
//
 Inject the DLL into all running processes
BOOL CWinHookInjector::InjectModuleIntoAllProcesses()
{
*sm_pHook = ::SetWindowsHookEx(
WH_GETMESSAGE,
(HOOKPROC)(GetMsgProc),
ModuleFromAddress(GetMsgProc),
0
);
return (NULL != *sm_pHook);
}

As you can see it makes a request to the system for registering WH_GETMESSAGE hook. The server executes this method only once. The last parameter of SetWindowsHookEx() is 0, because GetMsgProc() is designed to operate as a system-wide hook. The callback function will be invoked by the system each time when a window is about to process a particular message. It is interesting that we have to provide a nearly dummy implementation of the GetMsgProc() callback, since we don't intend to monitor the message processing. We supply this implementation only in order to get free injection mechanism provided by the operating system.

After making the call to SetWindowsHookEx() , OS checks whether the DLL (i.e. HookTool.DLL) that exports GetMsgProc() has been already mapped in all GUI processes. If the DLL hasn't been loaded yet, Windows forces those GUI processes to map it. An interesting fact is, that a system-wide hook DLL should not return FALSE in its DllMain() . That's because the operating system validates DllMain() 's return value and keeps trying to load this DLL until its DllMain() finally returns TRUE .

A quite different approach is demonstrated by the CRemThreadInjector class. Here the implementation is based on injecting the DLL using remote threads. CRemThreadInjector extends the maintenance of the Windows processes by providing means for receiving notifications of process creation and termination. It holds an instance of CNtInjectorThread class that observes the process execution. CNtInjectorThread object takes care for getting notifications from the kernel-mode driver. Thus each time when a process is created a call to CNtInjectorThread ::OnCreateProcess() is issued, accordingly when the process exits CNtInjectorThread ::OnTerminateProcess() is automatically called. Unlike the Windows Hooks, the method that relies on remote thread, requires manual injection each time when a new process is created. Monitoring process activities will provide us with a simple technique for alerting when a new process starts.

CNtDriverController class implements a wrapper around API functions for administering services and drivers. It is designed to handle the loading and unloading of the kernel-mode driver NTProcDrv.sys. Its implementation will be discussed later.

After a successful injection of HookTool.DLL into a particular process, a call to ManageModuleEnlistment() method is issued inside the DllMain() . Recall the method's implementation that I described earlier. It examines the shared variable sg_bHookInstalled through the CModuleScope 's member m_pbHookInstalled . Since the server's initialization had already set the value of sg_bHookInstalled to TRUE , the system checks whether this application must be hooked up and if so, it actually activates the spy engine for this particular process.

Turning the hacking engine on, takes place in the CModuleScope::InitializeHookManagement() 's implementation. The idea of this method is to install hooks for some vital functions as LoadLibrary() API family as well as GetProcAddress() . By this means we can monitor loading of DLLs after the initialization process. Each time when a new DLL is about to be mapped it is necessary to fix-up its import table, thus we ensure that the system won't miss any call to the captured function.

At the end of the InitializeHookManagement() method we provide initializations for the function we actually want to spy on.

Since the sample code demonstrates capturing of more than one user supplied functions, we must provide a single implementation for each individual hooked function. This means that using this approach you cannot just change the addresses inside IAT of the different imported functions to point to a single "generic" interception function. The spying function needs to know which function this call comes to. It is also crucial that the signature of the interception routine must be exactly the same as the original WINAPI function prototype, otherwise the stack will be corrupted. For example CModuleScope implements three static methods MyTextOutA(),MyTextOutW() and MyExitProcess() . Once the HookTool.DLL is loaded into the address space of a process and the spying engine is activated, each time when a call to the original TextOutA() is issued, CModuleScope:: MyTextOutA() gets called instead.

Proposed design of the spying engine itself is quite efficient and offers great flexibility. However, it is suitable mostly for scenarios where the set of functions for interception is known in advance and their number is limited.

If you want to add new hooks to the system you simply declare and implement the interception function as I did with MyTextOutA/W() and MyExitProcess() . Then you have to register it in the way shown by InitializeHookManagement() implementation.

Intercepting and tracing process execution is a very useful mechanism for implementing systems that require manipulations of external processes. Notifying interested parties upon starting of a new processes is a classic problem of developing process monitoring systems and system-wide hooks. The Win32 API provides a set of great libraries (PSAPI and ToolHelp [16]) that allow you to enumerate processes currently running in the system. Although these APIs are extremely powerful they don't permit you to get notifications when a new process starts or ends up. Luckily, NT/2K provides a set of APIs, documented in Windows DDK documentation as "Process Structure Routines" exported by NTOSKRNL. One of these APIs PsSetCreateProcessNotifyRoutine() offers the ability to register system-wide callback function which is called by OS each time when a new process starts, exits or has been terminated. The mentioned API can be employed as a simple way to for tracking down processes simply by implementing a NT kernel-mode driver and a user mode Win32 control application. The role of the driver is to detect process execution and notify the control program about these events. The implementation of the Windows process's observer NTProcDrv provides a minimal set of functionalities required for process monitoring under NT based systems. For more details see articles [11] and [15]. The code of the driver can be located in the NTProcDrv.c file. Since the user mode implementation installs and uninstalls the driver dynamically the currently logged-on user must have administrator privileges. Otherwise you won't be able to install the driver and it will disturb the process of monitoring. A way around is to manually install the driver as an administrator or run HookSrv.exe using offered by Windows 2K "Run as different user" option.  

Last but not least, the provided tools can be administered by simply changing the settings of an INI file (i.e. HookTool.ini ). This file determines whether to use Windows hooks (for 9x and NT/2K) or CreateRemoteThread() (only under NT/2K) for injecting. It also offers a way to specify which process must be hooked up and which shouldn't be intercepted. If you would like to monitor the process there is an option (Enabled) under section [Trace] that allows to log system activities. This option allows you to report rich error information using the methods exposed by CLogFile class. In fact ClogFile provides thread-safe implementation and you don't have to take care about synchronization issues related to accessing shared system resources (i.e. the log file). For more details see CLogFile and content of HookTool.ini file.

Sample code

The project compiles with VC6++ SP4 and requires Platform SDK. In a production Windows NT environment you need to provide PSAPI.DLL in order to use provided CTaskManager implementation.

Before you run the sample code make sure that all the settings in HookTool.ini file have been set according to your specific needs.

For those that will like the lower-level stuff and are interested in further development of the kernel-mode driver NTProcDrv code, they must install Windows DDK.

Out of the scope

For the sake of simplicity these are some of the subjects I intentionally left out of the scope of this article:

  • Monitoring Native API calls
  • A driver for monitoring process execution on Windows 9x systems.
  • UNICODE support, although you can still hook UNICODE imported APIs

Conclusion

This article by far doesn't provide a complete guide for the unlimited API hooking subject and without any doubt it misses some details. However I tried to fit in this few pages just enough important information that might help those who are interested in user mode Win32 API spying.

【数据集】CAMS 全球生物质燃烧排放 GFAS(基于火灾辐射功率) CAMS 全球生物质燃烧排放 GFAS(基于火灾辐射功率) 阅读详情

相关推荐

emqx Java 订阅以及发送 结合若依框架

emqx Java 订阅以及发送 结合若依框架

Spo的博客 1617

API hooking revealed

Download source files - 69 Kb Download demo project - 139 Kb Introduction Intercepting Win32 API calls has always been a challenging subject among most of the Windows developers and I have t

执着我一生[F.S.T] 3369

告别WPS与Office兼容性噩梦:用Aspose.Words生成Word/PDF时统一页码的终极方案

本文深入探讨了使用Aspose.Words解决WPS与Office文档页码兼容性问题的终极方案。通过分析分页符处理机制的差异,提供Java代码实现智能检测和移除问题分页符的方法,确保Word/PDF文档在不同平台显示一致的页码,特别适用于合同、标书等对格式要求严格的场景。

weixin_27966471的博客 147

经典文章-API Hook Revealed

原文: Intercepting Win32 API calls has always been a challenging subjectamong most of the Windows developers and I have to admit, its been oneof my favorite topics. The term Hooking represent

phphot 4304

MFC+Modbus-Tcp协议实现温湿度传感器采集

本文简单介绍MFC使用-Tcp通信实现系列MODBUSTCP型温湿度传感器采集数据。

zhigang_zhao的博客 2836

color demura原理_AMOLED中的补偿技术之外部光学补偿(Demura)

DAS BG CTO知识管理科 出品第696篇推文AMOLED显示屏生产过程中由于材料、工艺等原因,会有部分产品出现画面显示亮度不均的现象,也就是Mura,这种亮度不均的斑点痕迹会给视觉上带来不舒适感,留有这种痕迹的产品无法达到终端客户的规格要求,一般只能报废或降级处理。针对AMOLED生产工艺的外部补偿系统是将存在Mura不良的显示屏通过先进的子像素级光学成像技术和软件算法消除Mura纹 (即D...

weixin_36073392的博客 9838

经典文章-API Hook Revealed - 1

<br />转:http://hi.baidu.com/techicey/blog/item/3a7d46c8f58fe5107f3e6fac.html 经典文章-API Hook Revealed - 12008-11-18 19:35原文:<br /> Intercepting Win32 API calls has always been a challenging subject among most of the Windows developers and I have to admit

abin_gha的专栏 1165

CubeMX实战:ETH+LWIP+FreeRTOS网络工程从零搭建与AC6编译优化

本文手把手教你使用STM32CubeMX从零搭建集成以太网(ETH)、LWIP协议栈和FreeRTOS的嵌入式网络工程。文章详细解析了外设配置、协议栈调优、任务规划等关键步骤,并重点分享了如何解决ARM Compiler 6(AC6)的兼容性问题,实现编译速度与稳定性的双重提升,助你快速构建稳定的网络应用原型。

n2o3p4的博客 413

经典文章-API Hook Revealed - 3

翻译:一、序言对大多数的Windows开发者来说,如何在Win32系统中对API函数的调用进行拦截一直是项极富挑战性的课题,因为这将是对你所掌握 的计算机知识较为全面的考验,尤其是一些在如今使用RAD进行软件开发时并不常用的知识,这包括了操作系统原理、汇编语言甚至是关于机器指令代码的(听上 去真是有点恐怖,不过这是事实)。当前广泛使用的Windows操作系统中,像Win 9x和Win NT/2K,都提供了一种比较稳健的机制来使得各个进程的内存地址空间之间是相互独立,也就是说一个进程中的某个有效的内存

abin_gha的专栏 861

打开 AI 投研新时代 —— 深度解析 GitHub 高星项目 daily_stock_analysis

GitHub热门开源项目"daily_stock_analysis"是一款AI驱动的智能股票分析工具,能自动抓取行情数据、分析新闻语义并生成结构化报告。该项目采用Python开发,通过GitHub Actions实现全自动运行,支持邮件、企业微信等多渠道推送。核心功能包括AI决策仪表盘、多数据源整合和零成本部署方案,特别适合需要自动化投研辅助的个人投资者。项目强调其仅为分析工具而非投资建议,提醒用户注意AI模型的潜在误差。该工具通过智能化处理重复工作,帮助投资者提升决策效率,成为量化投资

陈奕昆的博客 1555

Arcgis建筑面shp由DSM和DEM获取高度拉伸并可视化

Arcgis建筑面shp由DSM和DEM获取高度拉伸并可视化

yilvyangguang520的博客 4005

API Hook Revealed

http://blog.csdn.net/VsirSoft/archive/2008/11/18/3324299.aspx

167

yolov11添加P2小目标检测头与添加P6超大目标检测头

本文介绍了YOLO目标检测模型中上下采样的原理及应用。上采样通过插值算法放大特征图,YOLO通常采用最近邻插值;下采样则通过带步长的卷积缩小特征图提取高层语义特征。文章详细阐述了这两种操作在YOLO中的实现方式、结构特点及对称性问题,指出下采样后会使用C3模块进行特征整合,上采样后通过concat抑制分割感。此外,还分析了不同分辨率特征图适合检测不同尺寸目标的原因,并提出添加4倍小目标检测头的方法,即对上采样后的特征进行concat和C3模块处理。最后给出了YOLOv5原模型结构和添加4倍检测头后的结构对比

m0_64661770的博客 826

API hooking revealed(API挂接透露)-伊沃·伊万诺夫

API hooking revealed By Ivo Ivanov The article demonstrates how to build a user mode Win32 API spying system   Introduction  (介绍) Intercepting Win32 API calls has always been a challenging subjec

zbc_vc的专栏 1533

vb 6.0并口开发操作实例

vb6并口开发,简体中文,试例内有inpout32.dll动态链接库

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

揭示Win32 API拦截细节/API hooking revealed (3)

[cpp]view plaincopy 1.//Activate/Deactivatehookingengine 2.BOOLCModuleScope::InstallHookMethod(BOOLbActivate,HWNDhWndServer) 3....{ 4.BOOLbResult;...

weixin_34418883的博客 92

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

生产级机器学习:从模型上线到系统稳定的关键工程实践

机器学习模型部署不是开发终点,而是系统性工程挑战的起点。当模型脱离训练环境进入真实业务流,其行为受特征延迟、服务依赖、数据漂移、资源约束和合规要求等多重因素影响。本文围绕生产环境中最常被忽视的四大核心问题——特征可用性保障、低延迟推理设计、防御性监控与漂移检测、可审计的模型治理——展开深度解析。结合金融风控与电商推荐等高后果场景的真实案例,揭示95%以上的线上故障源于工程疏漏而非算法缺陷。内容涵盖特征fallback语义对齐、eBPF级延迟诊断、KL散度动态基线告警、GitOps驱动的灰度回滚、以及将监管条

weixin_33739646的博客 442

python-英语学习-mp3文件按时分段分片-时间统计功能-tinytag

使用Python与tinytag库,可高效统计MP3文件总时长、定位累计达指定时长(如75分钟)的首个文件,并按30分钟为单位自动分组复制至子目录,支持路径自定义与错误处理,适用于英语学习资料等音频管理场景。

插件开发 50

C++20-概念与约束

C++ 20 概念与约束详解

m0_74189279的博客 236

Java 泛型详解:为什么要用泛型?实战+避坑(CSDN)

在没有泛型之前,集合只能存放Object类型对象,取出元素必须强制类型转换,极易出现ClassCastException运行时异常。Java泛型实现了编译期类型检查,把类型错误提前到编译阶段,同时减少强制类型转换代码,是集合框架、工具类开发的基础。Java泛型是伪泛型,编译之后字节码会擦除泛型信息:List<String> 和 List<Integer> 在运行时都是List。泛型的核心价值:编译期类型安全 + 消除强制转换,掌握擦除原理和PECS原则,写出更健壮的集合与工具类代码。extends /?

2502_93522185的博客 425

import cn.hutool.core.collection.CollUtil常用库介绍一下

在平时的 Java 开发中,只要涉及到集合的判空、去重、求交集/差集、List 转 Map 等操作,都可以优先看看。

qq_26889291的博客 257

从0开发游戏引擎-对象管理器ObjectManage实现

📚依赖知识:Node 类(zOrder 成员)、2D 游戏对象 Cobject(colliderWith / isRelease)。

qq_33531923的博客 199

用 Python 给长文做排版体检:图够不够、段落是不是太长

如果只按字符数硬算,代码块会被当成正文,一张 30 行的代码贴进去,立刻触发「连续正文 800 字」。清单和小标题也一样,它们本来就是分行内容,视觉密度低。import re[](path)RE_MOUNT = re.compile(r"^\[\[IMG:[^\]]+\]\]\s*$") # [[IMG:path|caption]] 独占一行RE_HEAD = re.compile(r"^#{1,6}\s") # 标题") # 引用块。

邱华林的博客 377

《AI 编程 Harness 实战手册》08|安全边界检查_如何确认防护有效

本文介绍如何有效验证AI Agent安全边界是否真正生效。针对配置文件虽正确但运行时可能失效的五大风险(如沙箱未启用、环境变量泄漏、hook崩溃等),提出三重验证机制:静态检查、系统层运行时测试(boundary_probe.py)与Agent行为演练(agent_drill.py)。通过基线对比法,精准识别写入、网络、凭据、环境变量等限制是否实际生效。实测显示,即使配置看似完整,若遗漏清理环境变量,仍可能导致密钥泄露。最终提供可执行脚本与检查清单,确保安全防护“真管用”。

forest_09的博客 321

Java 面试题:数组和 List 如何快速互转?最佳方案是什么?(其他高频面试API)

业务需求推荐 APIList 判断元素是否存在contains()List 根据条件查询单个对象List 根据条件查询多个对象List 判断是否存在符合条件的数据anyMatch()List 排序后快速查找Map 根据 Key 查询 Valueget()Map 判断 Key 是否存在大量数据判断元素是否存在List 根据 ID 高频查询List 转 HashMap两个 List 根据 ID 关联一个 List 转 Map。

两点 616

c++ list 基础使用+底层实现

介绍了list的常用接口,并且对一些常见的接口进行了模拟实现,尤其是ist的迭代器尤为重要。

晴天的博客 231
上一篇: 经典文章-API Hook Revealed - 1
下一篇: 经典文章-API Hook Revealed - 3
HelloBj
博客等级 码龄18年 36粉丝 21原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值