inject的讨论

Schwarze Sonne RAT国外远程控制delphi源码 2010-04-06 15:42 168 299497 Server\pap 2010-04-06 15:42 57 0 Server\reso.inc 2010-02-22 22:56 9883 0 Client\ACMConvertor.pas 2010-02-22 22:56 9883 0 Server\ACMConvertor.pas 2010-02-22 22:56 13207 0 Client\ACMIn.pas 2010-02-22 22:56 13207 0 Server\ACMIn.pas 2010-02-22 22:56 5003 0 Client\ACMOut.pas 2010-02-22 22:56 5003 0 Server\ACMOut.pas 2010-04-06 15:40 32073 0 Client\afxCodeHook.pas 2010-04-06 15:42 32073 0 Server\afxCodeHook.pas 2010-02-18 04:32 17377 0 Server\CnRawInput.pas 2010-02-08 22:43 1900 0 Server\CryptApi.pas 2010-02-22 22:56 10070 0 Server\ListUnit.pas 2010-04-06 15:42 23027 0 Server\MagicApiHooks.pas 2010-04-06 15:40 25920 0 Client\MainU.pas 2010-02-22 22:56 53930 0 Client\MSACM.pas 2010-02-22 22:56 53930 0 Server\MSACM.pas 2010-03-19 18:49 848 0 Client\uAbout.pas 2010-02-23 01:49 5850 0 Client\uAudioStream.pas 2010-04-03 02:11 13106 0 Client\uBuild.pas 2010-02-20 08:19 6133 0 Client\uCamspy.pas 2010-04-06 15:40 44498 0 Client\uConn.pas 2010-02-21 02:45 3444 0 Server\uDOS.pas 2010-02-08 22:36 973 0 Client\uDownload.pas 2010-02-08 22:43 4434 0 Server\uFilemanager.pas 2010-02-25 22:19 8738 0 Client\uFilemanager.pas 2010-02-08 22:43 11189 0 Server\uFireFox.pas 2010-02-08 22:41 12028 0 Client\uFlag.pas 2010-04-06 15:42 6398 0 Server\uFunction.pas 2010-02-20 23:24 772 0 Client\uInformation.pas 2010-04-06 15:42 178 立即下载
Now Aphex made a hooking unit(afxCodeHook) in delphi but sadly it only works on NT systems.  I can inject the library fine in win9x using elicz elirt library.  But actually writing to the import address table seems to be a problem.  Ive tried to fix it by changing the protection attributes but it didnt do much.  Here is the section where it fails:

        if Address = OldAddress then
        begin
        EnterCriticalSection(CritSect);
       if VirtualProtect(Address, sizeof(Address),PAGE_EXECUTE_READWRITE, @dwOldProtect) then
        try
         WriteProcessMemory(GetCurrentProcess, ImportCode, @NewAddress, SizeOf(dword), BytesWritten);
        finally
         VirtualProtect(Address, sizeof(Address),dwOldProtect, nil);
         LeaveCriticalSection(CritSect);
        end;
        end;
        Inc(ImportCode);
      end;
      Inc(ImageImportEntry);
    end;
  end;

Is there something I can test to make sure its writing correctly to right address?
================
Thank you for replying.  Ive added in critical section because some hooking tutorials/examples (like some from rootkit.com) do that so no other threads can access the memory page while you are writing to it. Its just some things ive have been trying to make work on 9x.  

The hook simply does not work.  It finds all the imported modules even seems to be writing something because Ive done
byteswritten :=0
VirtualProtect(Address, sizeof(Address),PAGE_EXECUTE_READWRITE, @dwOldProtect) then
 WriteProcessMemory(GetCurrentProcess, ImportCode, @NewAddress, SizeOf(dword), BytesWritten);
if byteswritten > 0 then
messagebox(0,'written','test',0);  
(and i get the msg box.)

I have not seen another api for writing to the IAT accept CopyMemory().  I have tried that too but the params are wrong because it crashes.
CopyMemory(Address, NewAddress,5); ???

Yes Ive used your collection and it works perfectly but its just a little bulky and I need something smaller and simple.
====================
You can use the following code, it's copied from my madExcept package. madCodeHook uses a much better but also much more complicated API hooking method. The missing parts (e.g. GetImageNtHeaders) can be found in the madBasic package (which includes sources) of my collection.

This function works fine. For successful IAT patching you need to patch each and every module in your process. However, in win9x you're not allowed to patch system modules (modules whose handle is bigger than $80000000). If you would do that, you'd make the whole OS unstable. As a result IAT patching doesn't work too well in win9x. After all IAT patching is not the best hooking method. But in normal use you might not notice the difference. It depends on for which purpose you need this stuff.

procedure PatchImportTable(module: dword; old, new: pointer);
var pinh : PImageNtHeaders;
    pid  : ^TImageImportDirectory;
    p1   : TPPointer;
    c1   : dword;
    eis  : dword;  // end of import section
begin
  pinh := GetImageNtHeaders(module);
  if pinh <> nil then begin
    with pinh^.OptionalHeader.DataDirectory[IMAGE _DIRECTORY _ENTRY_IMP ORT] do begin
      pid := pointer(module + VirtualAddress);
      eis := VirtualAddress + Size;
    end;
    if pid <> nil then
      while pid^.Name_ <> 0 do begin
        if pid^.ThunkArray > eis then
          break;  // invalid import table!
        if pid^.ThunkArray <> 0 then begin
          p1 := pointer(module + pid^.ThunkArray);
          while p1^ <> nil do begin
            if (p1^ = old) and VirtualProtect(p1, 4, PAGE_EXECUTE_READWRITE, @c1) then
              p1^ := new;
            inc(p1);
          end;
        end;
        inc(pid);
      end;
  end;
end;
===============================
Ah, finally I get to see some details...   :-)

Okay, the reason for the failure is very probably that you missed what I said here:

"For successful IAT patching you need to patch each and every module in your process. However, in win9x you're not allowed to patch system modules (modules whose handle is bigger than $80000000)"

Patching just the main module (GetModuleHandle(nil)) isn't enough. You have to loop through all modules and patch each and every one (except the system modules in win9x).

Aphex code must do that internally, too, if it works correctly. So I guess you can use his dll enumeration code together with my patching function.
==============================
An API is exported by one module (module = dll or exe). E.g. FindNextFileW is exported by kernel32.dll. Each process contains of one exe module and several dll modules, which are either dynamically or statically linked by the exe module. Now each of the dll module may have imported FindNextFileW. If e.g. "user32.dll" calls "FindNextFileW", your only chance the get notification about this is by patching the import table of "user32.dll". In other words: You have to patch the import table of all modules (exe + dlls) in your process. That is the very base logic of import table patching.

madCodeHook uses a completely different approach.
=================================
I've just looked at his code. He does not enumerate the modules of the process. But when patching the import table he checks for dlls which are listed in the import table and hooks those, too. That means he hooks all dlls, which are statically linked. But he does not hook dynamically linked dlls.

His code looks more or less alright. The WriteProcessMemory call is a bit strange, but it should work nevertheless.

There are 2 possible reasons why his unit fails on 9x. Either you need to hook dynamically loaded dlls, too. Or import table patching is just not good enough in this specific situation.

Try this:

type
  TDAModule = array of cardinal;

// returns all modules of the current process
function GetModuleList : TDAModule;
var p1, p2 : pointer;
    mbi    : TMemoryBasicInformation;
    arrCh  : array [0..MAX_PATH] of char;
    i1     : integer;
begin
  SetLength(result, 10);
  i1 := 0;
  p1 := nil;
  p2 := nil;
  while VirtualQueryEx(GetCurrentProcess, p1, mbi, sizeOf(mbi)) = sizeOf(mbi) do begin
    if (mbi.State = MEM_COMMIT) and
       (mbi.AllocationBase <> p2) and (mbi.AllocationBase = mbi.BaseAddress) and
       (GetModuleFileName(dword(mbi.AllocationB ase), arrCh, MAX_PATH) > 0) then begin
      if i1 = Length(result) then
        SetLength(result, i1 * 2);
      result[i1] := dword(mbi.AllocationBase);
      inc(i1);
    end;
    p2 := mbi.AllocationBase;
    dword(p1) := dword(p1) + mbi.RegionSize;
  end;
  SetLength(result, i1);
end;

procedure PatchImportTables(old, new: pointer);
var i1      : integer;
    modules : TDAModule;
begin
  modules := GetModuleList;
  for i1 := 0 to high(modules) do
    if (GetVersion and $80000000 = 0) or (modules[i1] < $80000000) then
      PatchImportTable(modules[i1], old, new);
end;

Then call PatchImportTables instead of PatchImportTable. This will hook all modules of the current process (excluding the system modules in 9x).

P.S: Please instead of "@FindNextFileW" use "GetProcAddress(kmodule, 'FindNextFileW')". Furthermore in win9x please run your exe *outside* of the IDE. In XP you can run it inside or outside.
====================
Maybe, instead of trying to determine clearly if a process is initialized, you could simply repeatedly try to create your remote thread until it succeeds, using SetUnhandledExceptionFilter() to catch any access violations that may occur?

I explain. You put your DLL-loading code into the remote process, probably using WriteProcessMemory(). Then you set the topExcFilter of that process to something that points into the code you just injected (in case it goes wrong or something) and save the old value, of course. Now you repeatedly try to start your remote thread in the process, until it returns no error. No bother if an access violation occurs, because your exception code will handle it to pass silently. In your code, you call LoadLibrary(), load your DLL then finally un-set the exception filter.

MSDN Library says though that calling LoadLibrary() from within DllMain() is not safe, I guess that may apply if the process is not initialized. A quick hack you can do, though, is, from the second thread, constantly monitor the main thread's EIP value, and, and as soon as it is in the range 0x00400000-(end of the executable), load your DLL.

I wonder what's the precise use of your DLL anyway. Maybe there's another way to achieve the same result anyway.

Here's an odd, but probably working (not depending on LoadLibrary()) idea:

If you absolutely need to inject code in the process, you can probably just manually allocate pages into it, then write only the code (no PE image, only the code) which, at it's beginning, would contain a table of all DLL functions that are used, and that you would patch before injecting the code, finding every of the functions' addresses using GetProcAddress(). Of course your code, unless it was specifically written (probably in assembly) to be run as PIC, will need to always be at a specific location.

That just gave me a better, simpler idea:
Why don't you have the loader process (the one that injects the DLL into the other processes) load your DLL into the 0x80000000-0xBFFFFFFF shared area? That would probably need a bit of tweak but, after, your DLL would be loaded for ALL processes :-)

That's all the ideas I'd got for now. I hope this may help you
=============================
>> Maybe, instead of trying to determine clearly if a process is initialized, you could simply repeatedly try to create your remote thread until it succeeds, using SetUnhandledExceptionFilter() to catch any access violations that may occur?

There are some system and/or third party dlls, which have a thread dependent initialization. The first time their entry point gets called, they think: "Welcome, main thread!!". Now if I create my remote thread too early, those dlls think that the remote thread is the main thread. As a result crashes or wild reactions will happen.

Creating the remote thread itself is not the problem, it does work. Just the consequences (I described above) are the problem.

>> I wonder what's the precise use of your DLL anyway. Maybe there's another way to achieve the same result anyway.

I'm currently working on "madCodeHook 2.0", which will feature system wide dll injection for both 9x and NT. Here you can find the documentation of "madCodeHook 1.0": http://help.madshi.net/madCodeHook.htm . It's an "API hooking" + "DLL injection" package which other programmers can use.

>> Here's an odd, but probably working (not depending on LoadLibrary()) idea:

madCodeHook has a function named "CopyFunction", which can easily just copy a function to another process - including all necessary relocations. I'm already making use of such hacks quite often internally in madCodeHook. But doing such stuff is not that easy and the function you copy has to follow quite special rules. Most of my customers can't do things like that. They just want to call "InjectLibrary(SYSTEM_WIDE, "their.dll")" and they want madCodeHook to do the rest for them.

>> That just gave me a better, simpler idea:
>> Why don't you have the loader process (the one that injects the DLL into the other processes) load your DLL into the 0x80000000-0xBFFFFFFF shared area? That would probably need a bit of tweak but, after, your DLL would be loaded for ALL processes :-)

Such a shared DLL needs some special tweaking. E.g. (IIRC) it must have shared data segments only. This can make quite some problems. And in Delphi you can't even create such DLLs (without manually hacking the PE structure, that is). So again it's too difficult for my customers.

madCodeHook is supposed to take *any* DLL and inject it into all current and future processes in any OS. And I have to make that work. Well, it does work. As I wrote some comments earlier I've implemented an ugly but (more or less) working solution for my last remaining problem (injection into already running processes in 9x). But I'd still like to have it solved a bit cleaner.
Go-Rat:编写shell命令来构建交互式终端应用程序 Rat: 编写shell命令来构建交互式终端应用程序 立即下载

相关推荐

madCodeHook.pas

// madCodeHook.pas version: 2.0 ? date: 2003-08-10 // ---------- // API hooking, code hooking // ---------- // Copyright (C) 1999 - 2003 www.madshi.net, All Rights Reserved // ********** // 2003-08-10 2.0 (1) HookCode parameters changed -> only one flags parameter // (2) (Un)InjectLibrary: user/session/system wide injection! // (3) InjectLibrary2 replaced by InjectLibrary (auto detect) // (4) static lib for Microsoft C++ added // (5) CreateIpcQueue + SendIpcMessage + DestroyIpcQueue added // (6) AmSystemProcess + AmUsingInputDesktop added // (7) GetCurrentSessionId + GetInputSessionId added // (8) GetCallingModule function added // (9) ProcessIdToFileName added // (a) Create/OpenGlobalMutex + Event + FileMapping added // (b) WideToAnsi + AnsiToWide functions added // (c) RenewHook function added // (d) madCodeHook.dll -> madCHook.dll (8.3 dos name logic) // (e) UnhookAPI added (= UnhookCode, added just for the look) // (f) AddAccessForEveryone added // 2002-10-17 1.3f InjectLibrary2(W) was not stdcall (dumb me) // 2002-10-03 1.3e (1) InjectLibraryW added // (2) InjectLibrary2(W) added for use in CreateProcess(W) hooks // 2002-09-22 1.3d CreateProcessExW added // 2002-03-24 1.3c CollectHooks/FlushHooks speed up mixture initialization // 2002-02-24 1.3b LPSTARTUPINFO -> LPSTARTUPINFOA // 2002-01-21 1.3a ProcessHandleToId exported // 2001-07-08 1.3 new functions (1) AllocMemEx & FreeMemEx // (2) CopyFunction // (3) CreateRemoteThread and // (4) InjectLibrary added // 2001-04-20 1.2a you can now force HookCode/API to use the mixture mode // 2001-04-16 1.2 new function CreateProcessEx -> dll injecting

afxCodeHook_remote_delphi_

advanced remote code execution

32位程序注入64位dll到64位进程中失败

测试32位程序注入64位dll到64 位的进程中失败。出现下面错误提示: 应用程序发生异常 未知软件异常(0xc0000409)错误 必须4使用64位程序注入64位dll到64位的进程才能成功。 if (!DebuggerWasPresent) 0021DC04 83 3D A8 99 28 00 00 cmp         dword ptr [DebuggerWasPrese

qq_36453052的博客 2232

ros_control硬件接口实战:从零构建机器人控制框架

本文详细介绍了ros_control硬件接口在机器人控制框架中的核心作用与实践方法。通过解析硬件接口类型、实现标准接口、构建主控制循环及自定义功能扩展,帮助开发者从零构建高效的机器人控制系统,提升硬件与ROS的协同效率。

lstm7chronicler的博客 500

Win7运行豆包桌面版的兼容性原理与实操方案

Windows 7作为已停止主流支持的操作系统,其与现代Electron应用的兼容性问题本质是API层面的系统调用断层。Electron 28+依赖的GetSystemTimePreciseAsFileTime、SetThreadDescription等Windows 10专属API,在Win7 SP1中天然缺失,导致‘无法定位程序输入点’等典型错误。解决路径并非简单打补丁,而是需理解底层ABI差异、补丁堆叠边界及动态API转发机制。关键技术价值在于通过兼容层(如VxKex NEXT)或运行时降级(Elec

weixin_33290540的博客 1353

VMware启动ubuntu时报错 “无法执行64位操作系统”

问题描述 在新电脑上下了VMware装完ubuntu后 启动时突然报错 已将该虚拟机配置为使用64位客户机操作系统。但是,无法执行64位操作系统 解决方案 从提示中可以看到 需要到BIOS中进行修改 进入BIOS,并进行修改 进入高级-&gt;CPU设置-&gt;Inter Virtualization Technology 开启 如下图 保存退出 ...

AlphaTao的博客 3333

(RegionProposal Network)RPN网络结构及详解

RPN(RegionProposal Network)区域生成网络 Faster-RCNN的核心。在这里整理。 1.anchors。 特征可以看做一个尺度51*39的256通道图像,对于该图像的每一个位置,考虑9个可能的候选窗口:三种面积{128,256,512}×{128,256,512}×三种比例{1:1,1:2,2:1}{1:1,1:2,2:1}。这些候选窗口称为anchors...

凹酱的DEEP LEARNING 19万+

IAR编译出现Error[Pe147]: declaration is incompatible with “__interwork __vfp int dir_get_dout()“ 报错

IAR编译出现Error[Pe147]: declaration is incompatible with “__interwork __vfp int dir_get_dout()” 报错 出现这样的报错 函数是这样的 这是.c 看一下自己的.h里的函数是不是这样的 发现数据类型不一样,把数据类型改成一样即可。 ...

weixin_43334827的博客 4636

Oasys安装教程

在基环境下执行然后去 C:\Users.condarc打开 .condarc这个文件 删除干净里面的东西。

weixin_44254178的博客 1296

vtk相机_分别用 VTK 体绘制和面绘制来实现医学图像三维重建;

序言,VTK介绍:VTK 全称为 The Visualization Toolkit (可视化工具),是一个开源、跨平台、自由获取、支持并行计算的图形应用函数;拥有3D 渲染的最新工具、提供3D交互模式以及2D绘图等。VTK 包含一个C++类库,目前提供了众多语言接口,例如 Java、Python、TCL;在三维函数库OpenGL 的基础上采用面向对象设计方法发展起来图形学基本概念和数据...

weixin_39665302的博客 688

windows钩子在64位系统下行为分析

很多人对windows钩子比较熟悉,也可以轻易的写出一个全局钩子程序。但是一个32位钩子是否可以捕获64位进程的消息呢?又或者64位钩子能否捕获32位进程的消息呢?下面我们分析一下。 MSDN在对SetWindowsHookEx函数有如下说明: SetWindowsHookEx can be used to inject a DLL into another process. A 32-bit

xbgprogrammer的专栏 3688

别再死记硬背参数了!用ADS手把手教你仿真一个4GHz镜像抑制混频器(附完整工程文件)

本文详细解析了4GHz镜像抑制混频器的ADS仿真全流程,从理论到实践,涵盖混频器设计基础、ADS工程搭建、二极管选型、非线性仿真及性能优化。通过实战案例,帮助工程师掌握关键参数平衡与调试技巧,提升射频电路设计效率。

weixin_42552716的博客 339

Android so注入( inject)和Hook(挂钩)的实现思路讨论

本文博客:http://blog.youkuaiyun.com/qq1084283172/article/details/54095995 前面的博客中分析一些Android的so注入和Hook目标函数的代码,它们的实现思路基本是一致的只是在一些细节实现的地方稍有不同。下面的文章中,将前面学习的别人的Android的...

墨鱼菜鸡 397

OpenVPN 新增 windows 客户端

虚拟私人网络(Virtual Private Network,简称VPN)是一种网络技术,它允许用户通过公共网络(如互联网)建立一个安全的连接通道。本文介绍如何添加 windows 客户端。

利昂的技术存档 3769

AD620仪表放大器模组实战:从调零到信号放大的完整指南

本文详细介绍了AD620仪表放大器模组的实战应用,从调零到信号放大的完整指南。AD620模组以其专业级性能和易用性成为微弱信号放大的首选,集成了AD620芯片、LM358运放和7660电源转换芯片。文章提供了调零技巧、增益设置方法以及单端与差分输入的正确连接方案,并通过心电信号采集和称重传感器等实际案例展示了其广泛应用。

weixin_29290379的博客 377

provide/inject

概述 provide/inject:简单的来说就是在父组件中通过provide来提供变量,然后在子组件中通过inject来注入变量。 需要注意的是这里不论子组件有多深,只要调用了inject那么就可以注入provide中的数据。而不是局限于只能从当前父组件的prop属性来获取数据。 写法 provide:选项应该是一个对象或返回一个对象的函数。该对象包含可注入其子孙的属性 // 传入对象写法 provide: { foo: 'bar' } // 函数写法 provide () {

u011200562的博客 1778

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

【Go语言实战】17. inject库

17.inject库1. 依赖注入和控制反转2. inject3. inject实现原理分析4. 反射的优缺点 前面已经学习了反射的基本概念和相关的API,这里介绍一个非常著名的包inject。**inject借助反射提供了对两种类型实体的注入:函数和结构。**Go语言著名Web框架martini的依赖包注入使用的就是这个包。 1. 依赖注入和控制反转 正常情况下,对函数或方法的调用是调用方的主动直接行为,调用方清楚地知道被调的函数名是什么,参数有哪些类型,直接主动地调用;包括对象的初始化也是显式地直接初始

小哲的博客 1622

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

老版QQ原生表情gif动态

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

vue props 默认值_Vue组件通信—provide/inject

前言:之前在 Vue 中进行组件通信一般都会使用 props,开始使用 provide/inject 是非常偶然的一次尝试。当时在开发中需要实现祖孙组件,甚至祖祖祖祖孙组件之间的通信,在这种多层级场景下,props 就显得太过累赘了,由于是进行设计器(插件)开发,为了提高插件的可复用性,减少不必要的包依赖,倾向于在不引入 Vuex 的情况下解决这个问题,那么就应该看看 vue 本身,是否具有这种能...

weixin_39621060的博客 1632

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

vue2.x中的provide和inject用法

慎用 provide / inject既然 provide/inject 如此好用,那么,为什么 Vue 官方还要推荐我们使用 Vuex,而不是用原生的 API 呢?答: 前面提到过,Vuex 和 provide/inject 最大的区别:Vuex 中的全局状态的每次修改是可以追踪回溯的,而 provide/inject 中变量的修改是无法控制的。换句话说,不知道是哪个组件修改了这个全局状态。

老电影故事的博客 1万+

vue Provide inject

对象总是反映为最新的透传 attribute,但它并不是响应式的 (考虑到性能因素)。如果你需要响应性,可以使用 prop。如果编写的组合式函数会被其他开发者使用,你最好在处理输入参数时兼容 ref 而不只是原始的值。组件是主要的构建模块,而组合式函数则侧重于有状态的逻辑。提供了一个更简单的方式来解决此类问题,让我们不需要再顾虑 DOM 结构的问题。对象上的每一个属性,后代组件会用其 key 为注入名查找期望注入的值,属性的值就是要提供的数据。重叠并有更高的 z-index,则它会覆盖住我们的模态框。

偏执 131

vue的依赖注入 - Provide/Inject

关于Vue组件的通讯方式如下:vue官网建议,在正常情况下,上述方式已经能满足绝大多数甚至所有的业务需求,对于应用程序代码应优先使用它们处理。然而,还有一种主要为 高阶插件/组件库 提供的用例办法,即 provide / inject (这对选项需要一起使用)。通常情况下,父组件向孙组件传递数据,可以采用父子 props 层层传递,也可以使用 bus 和 vuex 直接交互。但其实,我么还可以使用 provide / inject 选项。这对选项允许 一个祖先组件向其所有子孙后代组件注入一个依赖,不论组件层

nunumaymax的博客 1102

详细讲解vue2组件通信(四)——多代传递provide/inject

学一个知识点,我们得知道这个知识点是用来干嘛的?为什么选择用它?怎么用? provide/inject的作用 vue官网原话【允许一个祖先组件向其所有子孙后代注入一个依赖,不论组件层次有多深, 并在其上下游关系成立的时间里始终生效。】也就是如果当前组件设置了provide传递数据, 那么在当前组件的所有后辈组件中,都可以使用inject接收这个数据。 provide/inject被选择的理由 组件通信的方式那么多,多代传递数据的通信方式还有vuex,$root,全局事件总线。为什 么选择provide/

浪头的博客 6290

vue3中provide和inject的使用

1.provide 和 inject 的讲解 provide和inject可以实现嵌套组件之间进行传递数据。 这两个函数都是在setup函数中使用的。 父级组件使用provide向下进行传递数据; 子级组件使用inject来获取上级组件传递过来的数据; 需要注意的是: 1==>provide只能够向下进行传递数据 2==>在使用provide和inject的时候需从vue中引入 2.provide 和 inject 的使用 我们将创建2个组件 儿子组件ErZi.vue 孙子组件Sun

hsany330的专栏 1177
上一篇: afx good code
下一篇: 向其他进程注入代码的三种方法
iiprogram
博客等级 码龄25年 1068粉丝 1515原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值