cmder lib_base.bat分析学习

0x00 前言

lib_base.bat分析学习是在init.bat的基础上进行调用的。
其他相关分析文章
cmder Cmder.bat分析学习
DIY自己的cmder.exe
cmder init.bat分析学习

为了更清晰的标识,使用新的注释方法。

0x01 正文

1. 1~10行

@echo off

set lib_base=call "%~dp0lib_base.cmd"

if "%~1" == "/h" (
    %lib_base% help "%~0"
) else if "%1" neq "" (
    call :%*
)

在这里插入图片描述

这里的call需要进行举例说明:
脚本链接

@echo off
echo %*
exit /b
:a
echo a
:b 
echo b

在这里插入图片描述

2. help部分

    for /f "tokens=* delims=:" %%a in ('type "%~1" ^| %WINDIR%\System32\findstr /i /r "^:::"') do (
        rem echo a="%%a"

        if "%%a"=="." (
            echo.
        ) else if /i "%%a" == "usage" (
            echo %%a:
        ) else if /i "%%a" == "options" (
            echo %%a:
        ) else if not "%%a" == "" (
            echo %%a
        )
    )

    pause
    exit /b

在这里插入图片描述

3.cmder_shell

echo %comspec% | %WINDIR%\System32\find /i "\cmd.exe" > nul && set "CMDER_SHELL=cmd"
echo %comspec% | %WINDIR%\System32\find /i "\tcc.exe" > nul && set "CMDER_SHELL=tcc"
echo %comspec% | %WINDIR%\System32\find /i "\tccle" > nul && set "CMDER_SHELL=tccle"

if not defined CMDER_CLINK (
    set CMDER_CLINK=1
    if "%CMDER_SHELL%" equ "tcc" set CMDER_CLINK=0
    if "%CMDER_SHELL%" equ "tccle" set CMDER_CLINK=0
)

if not defined CMDER_ALIASES (
    set CMDER_ALIASES=1
    if "%CMDER_SHELL%" equ "tcc" set CMDER_ALIASES=0
    if "%CMDER_SHELL%" equ "tccle" set CMDER_ALIASES=0
)

exit /b

在这里插入图片描述
这个部分其实就是进行了一个初始化:
CMDER_SHELL,CMDER_SHELL以及CMDER_ALIASES的初始化

4.update_legacy_aliases

    set "user_aliases=D:\VStart\tools\tools\cmder_cs\config\a.cmd"
    :: 这里其实就是判断文件存在不的意思
    type "%user_aliases%" | %WINDIR%\System32\findstr /i ";= Add aliases below here" >nul
    :: 如果不存在errorlevel==1
    if "%errorlevel%" == "1" (
        :: 打印
        echo Creating initial user_aliases store in "%user_aliases%"...
        :: 判断CMDER_USER_CONFIG是否存在
        if defined CMDER_USER_CONFIG (
            :: 备份当前的 aliases,且将user_aliases.cmd.default复制为新的aliases
            copy "%user_aliases%" "%user_aliases%.old_format"
            copy "%CMDER_ROOT%\vendor\user_aliases.cmd.default" "%user_aliases%"
        ) else (
            copy "%user_aliases%" "%user_aliases%.old_format"
            copy "%CMDER_ROOT%\vendor\user_aliases.cmd.default" "%user_aliases%"
        )
    )
    exit /b

在这里插入图片描述
这个update_legacy_aliases强制检测user_aliases有没有;=要是没有就要去复制了。相当于这个脚本是在为user_aliases.cmd进行服务的。

0x02 后记

感觉这里提前call的这一下,相当于python在提前进行一个import一样,只不过是变量的控制域的掌控问题罢了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
这段代码是用来加载一个名为 Octree_python_lib.so 的动态链接库,并定义了一些函数接口和函数参数的类型。下面是对每个定义的函数接口和参数类型的解释: - c_double_p: 定义了一个指向 double 类型的指针。 - c_uint16_p: 定义了一个指向 uint16 类型的指针。 - lib = cdll.LoadLibrary(os.path.dirname(os.path.abspath(__file__))+'/Octree_python_lib.so'): 加载 Octree_python_lib.so 动态链接库,并将其赋值给 lib 变量。 - lib.new_vector: 函数接口,返回类型为 c_void_p,无参数。 - lib.delete_vector: 函数接口,返回类型为 None,参数为 c_void_p。 - lib.vector_size: 函数接口,返回类型为 c_int,参数为 c_void_p。 - lib.vector_get: 函数接口,返回类型为 c_void_p,参数为 c_void_p 和 c_int。 - lib.vector_push_back: 函数接口,返回类型为 None,参数为 c_void_p 和 c_int。 - lib.genOctreeInterface: 函数接口,返回类型为 c_void_p,参数为 c_void_p、c_double_p 和 c_int。 - lib.Nodes_get: 函数接口,返回类型为指向 Node 类型的指针 (POINTER(Node)),参数为 c_void_p 和 c_int。 - lib.Nodes_size: 函数接口,返回类型为 c_int,参数为 c_void_p。 - lib.int_size: 函数接口,返回类型为 c_int,参数为 c_void_p。 - lib.int_get: 函数接口,返回类型为 c_int,参数为 c_void_p 和 c_int。 这些函数接口的具体功能需要根据实际的动态链接库 Octree_python_lib.so 来确定。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

王嘟嘟_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值