⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ddkbuild.cmd

📁 经典的文件透明加解密程序
💻 CMD
📖 第 1 页 / 共 4 页
字号:
goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: \ ResolveVar subroutine
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: / MakeShort subroutine
::   Two parameters. First parameter is the variable name, second is the path
::   to convert into a short filename.
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:MakeShort
setlocal ENABLEEXTENSIONS
:: Get the name of the variable we are working with and the path to convert
set VAR_NAME=%~1
set PATH_SHORT=%~dpns2
set PATH_EXTSHORT=%~xs2
if not "" == "%PATH_EXTSHORT%" set PATH_EXTSHORT=%PATH_EXTSHORT:~0,4%
set PATH_SHORT=%PATH_SHORT%%PATH_EXTSHORT%
endlocal & set %VAR_NAME%=%PATH_SHORT%
goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: \ MakeShort subroutine
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: / ErrorWithUsage subroutine
::   This one will take the passed in parameters and build a nice error
::   message which is returned to the user along with the usage hints.
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:ShowErrorMsg
@set OSR_ERRCODE=%~1
@set OSR_ERRMSG=%~2
@set OSR_ERRMSG=%OSR_ERRMSG:'="%
@set OSR_ERRMSG=ERROR #%OSR_ERRCODE%: %OSR_ERRMSG%
@echo.
%OSR_ECHO% %OSR_ERRMSG%
if DEFINED buildDirectory %OSR_ECHO% -^> Target directory: %buildDirectory%
goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: \ ErrorWithUsage subroutine
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: / SetVar subroutine
::   Param1 == name of the variable, Param2 == value to be set for the variable
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:SetVar
:: Get the name of the variable we are working with
setlocal ENABLEEXTENSIONS & set VAR_NAME=%1
endlocal & set %VAR_NAME%=%~2
goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: \ SetVar subroutine
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: / DetectVistaWDK subroutine
::   No parameters expected
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:DetectVistaWDK
setlocal ENABLEEXTENSIONS
:: Newer flag (starting with W2K8) is default
set OSR_AMD64FLAG=x64
:: The Vista WDK accepted *only* "AMD64", the newer W2K8 WDK accepts only "x64"
:: We detect the older one by checking the setenv.bat for a certain string
findstr /C:"Windows Server Longhorn" "%BASEDIR%\bin\setenv.bat" > NUL 2>&1 && set OSR_AMD64FLAG=AMD64
endlocal & set OSR_AMD64FLAG=%OSR_AMD64FLAG%
goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: \ DetectVistaWDK subroutine
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: / DetectBaseDirTemp subroutine
::   The first parameter is the list of directory names to check, separated by
::   blank spaces.
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:DetectBaseDirTemp
:: Get the name of the variable we are working with
if "%~1" == "" goto :EOF
setlocal ENABLEEXTENSIONS
call :CommonCheckMsg1
:: Try to find an installed DDK/WDK from the registry keys
if DEFINED OSR_REGAVAILABLE if not "%OSR_REGAVAILABLE%" == "0" (
  for %%i in (%~1) do @(
    call :RegTryBaseDirTemp "%%i"
  )
)
:: Try all the "default" locations
if not DEFINED BASEDIRTEMP (
  for %%i in (%~1) do @(
    for %%a in (WINDDK DDK) do @(
      call :BruteTryBaseDirTemp "%SystemDrive%\%%a\%%i"
      call :BruteTryBaseDirTemp "%ProgramFiles%\%%a\%%i"
    )
  )
)
endlocal & set BASEDIRTEMP=%BASEDIRTEMP%
goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: \ DetectBaseDirTemp subroutine
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: / RegTryBaseDirTemp subroutine
::   Attempt to find the install key in the registry.
::   This functions tests old-style DDKs and new-style WDKs.
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:RegTryBaseDirTemp
if DEFINED BASEDIRTEMP if exist "%BASEDIRTEMP%" goto :EOF
setlocal ENABLEEXTENSIONS
call :RegTryBaseDirTempSingle "%~1" "LFNDirectory" BASEDIRTEMP
if DEFINED BASEDIRTEMP if exist "%BASEDIRTEMP%" goto :RegTryBaseDirTemp_EOF
call :RegTryBaseDirTempSingle "%~1\Setup" "BUILD" BASEDIRTEMP
if DEFINED BASEDIRTEMP if exist "%BASEDIRTEMP%" goto :RegTryBaseDirTemp_EOF
if not DEFINED BASEDIRTEMP (endlocal & goto :EOF)
:RegTryBaseDirTemp_EOF
%OSR_ECHO% Found directory (%BASEDIRTEMP%) from install key
endlocal & set BASEDIRTEMP=%BASEDIRTEMP% & goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: \ RegTryBaseDirTemp subroutine
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: / RegTryBaseDirTempSingle subroutine
::   Attempt to find the install key in the registry.
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:RegTryBaseDirTempSingle
setlocal ENABLEEXTENSIONS
set REGSUBKEY=%~1
set REGVALUE=%~2
set VARIABLETOSET=%~3
set REGMAINKEY=HKLM\SOFTWARE\Microsoft\WINDDK
:: Test whether we can read the value below this key
reg query "%REGMAINKEY%\%REGSUBKEY%" /v "%REGVALUE%" > NUL 2>&1 || goto :RegTryBaseDirTempSingle_WOW64
for /f "tokens=2*" %%i in ('reg query "%REGMAINKEY%\%REGSUBKEY%" /v "%REGVALUE%"^|findstr /C:"%REGVALUE%"') do @(
  call :SetVar _SETVARIABLE "%%j"
)
endlocal & set %VARIABLETOSET%=%_SETVARIABLE%
:RegTryBaseDirTempSingle_WOW64
set REGMAINKEY=HKLM\SOFTWARE\Wow6432Node\Microsoft\WINDDK
:: Test whether we can read the value below this key
reg query "%REGMAINKEY%\%REGSUBKEY%" /v "%REGVALUE%" > NUL 2>&1 || goto :RegTryBaseDirTempSingle_EOF
for /f "tokens=2*" %%i in ('reg query "%REGMAINKEY%\%REGSUBKEY%" /v "%REGVALUE%"^|findstr /C:"%REGVALUE%"') do @(
  call :SetVar _SETVARIABLE "%%j"
)
endlocal & set %VARIABLETOSET%=%_SETVARIABLE%
:RegTryBaseDirTempSingle_EOF
endlocal
goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: \ RegTryBaseDirTempSingle subroutine
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: / BruteTryBaseDirTemp subroutine
::   Brute-force test the given directory.
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:BruteTryBaseDirTemp
if DEFINED BASEDIRTEMP if exist "%BASEDIRTEMP%" goto :EOF
setlocal ENABLEEXTENSIONS
:: We will not overwrite BASETEMPDIR if it has been set and is valid
:: Just try
set BASEDIRTEMP=%~1
%OSR_ECHO% Trying %BASEDIRTEMP% ...
if not exist "%BASEDIRTEMP%" (endlocal & goto :EOF)
endlocal & set BASEDIRTEMP=%BASEDIRTEMP% & goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: \ BruteTryBaseDirTemp subroutine
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Usage output
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:USAGE
@echo.
@echo USAGE:
@echo ======
@echo   %~n0 ^<target^> ^<build type^> ^<directory^> [flags] [-WDF] [-PREFAST]
@echo.
@echo Values for ^<target^>:
@echo    --------------------------------------------------------------------------
@echo     Target platform and OS   ^| Miscellaneous
@echo    --------------------------^|-----------------------------------------------
@echo     Target     ^| Windows     ^| CPU     ^| Base directory ^| Target alias(es)
@echo    ------------^|-------------^|---------^|----------------^|--------------------
@echo     -W2K       ^| 2000        ^| x86     ^| %%W2KBASE%%      ^|
@echo     -W2K64     ^| 2000        ^| Itanium ^| %%W2KBASE%%      ^| -W2KI64
@echo     -WXP       ^| XP          ^| x86     ^| %%WXPBASE%%      ^| -XP
@echo     -WXP64     ^| XP          ^| Itanium ^| %%WXPBASE%%      ^| -WXPI64, -XP64
@echo     -WXP2K     ^| 2000        ^| x86     ^| %%WXPBASE%%      ^| -XPW2K
@echo     -WNET      ^| 2003        ^| x86     ^| %%WNETBASE%%     ^|
@echo     -WNET64    ^| 2003        ^| Itanium ^| %%WNETBASE%%     ^| -WNETI64
@echo     -WNETXP    ^| XP          ^| x86     ^| %%WNETBASE%%     ^|
@echo     -WNETXP64  ^| XP          ^| Itanium ^| %%WNETBASE%%     ^|
@echo     -WNETAMD64 ^| 2003/XP x64 ^| x64     ^| %%WNETBASE%%     ^| -WNETX64, -WNETA64
@echo     -WNET2K    ^| 2000 SP3    ^| x86     ^| %%WNETBASE%%     ^| -WNETW2K
@echo     -WLH       ^| Vista/2008  ^| x86     ^| %%WLHBASE%%      ^|
@echo     -WLH2K     ^| 2000 SP4    ^| x86     ^| %%WLHBASE%%      ^|
@echo     -WLHXP     ^| XP          ^| x86     ^| %%WLHBASE%%      ^|
@echo     -WLHXP64   ^| XP          ^| Itanium ^| %%WLHBASE%%      ^|
@echo     -WLHNET    ^| 2003        ^| x86     ^| %%WLHBASE%%      ^|
@echo     -WLHNETI64 ^| 2003        ^| Itanium ^| %%WLHBASE%%      ^| -WLHNET64
@echo     -WLHNETX64 ^| 2003/XP x64 ^| x64     ^| %%WLHBASE%%      ^| -WLHNETA64
@echo     -WLHI64    ^| Vista/2008  ^| Itanium ^| %%WLHBASE%%      ^| -WLH64
@echo     -WLHX64    ^| Vista/2008  ^| x64     ^| %%WLHBASE%%      ^| -WLHA64
@echo     -NT4       ^| NT 4.0      ^| x86     ^| %%NT4BASE%%      ^|
@echo    --------------------------------------------------------------------------
@echo     Support for NT4 and W2K DDKs is deprecated and not checked anymore
@echo     in new versions. It may or may not work properly.
@echo    --------------------------------------------------------------------------
@echo.
@echo Values for ^<build type^>:
@echo       checked, chk     indicates a checked build
@echo       free, fre        indicates a free build
@echo.
@echo Remaining parameters ("opt!" = optional parameter):
@echo       ^<directory^>      path to build directory, try . (current directory)
@echo       [flags]    opt!  any flags you think should be passed to build (try /a
@echo                        for clean)
@echo       -WDF       opt!  performs a WDF build
@echo       -PREFAST   opt!  performs a PREFAST build
@echo.
@echo Special files:
@echo       The build target directory (where the DIRS or SOURCES file resides) can
@echo       contain the following files:
@echo       - %OSR_PREBUILD_SCRIPT%
@echo         Allows to include a step before the BUILD tool from the DDK is called
@echo         but after the environment for the respective DDK has been set!
@echo       - %OSR_POSTBUILD_SCRIPT%
@echo         Allows to include a step after the BUILD tool from the DDK is called,
@echo         so the environment is still available to the script.
@echo       - %OSR_SETENV_SCRIPT%
@echo         Allows to set (or override) _any_ environment variables that may exist
@echo         in the global environment. Thus you can set the base directory for the
@echo         DDK from inside this script, making your project more self-contained.
@echo.
@echo       DDKBUILD will only handle those files which exist, so you may choose to
@echo       use none, one or multiple of these script files.
@echo       (All scripts execute inside their current directory. Consider this!)
@echo.
@echo Examples:
@echo       ^"%~n0 -NT4 checked .^" (for NT4 BUILD)
@echo       ^"%~n0 -WXP64 chk .^"
@echo       ^"%~n0 -WXP chk c:\projects\myproject^"
@echo       ^"%~n0 -WNET64 chk .^"      (IA64 build)
@echo       ^"%~n0 -WNETAMD64 chk .^"   (AMD64/EM64T build)
@echo       ^"%~n0 -WNETXP chk . -cZ -WDF^"
@echo       ^"%~n0 -WNETXP chk . -cZ -PREFAST^"
@echo.
@echo       In order for this procedure to work correctly for each platform, it
@echo       requires an environment variable to be set up for certain platforms.
@echo       There is an auto-detection mechanism in this script, which will work best
@echo       if the DDK/WDK was installed using the normal installer (i.e. not just
@echo       copied). The auto-detection is based on the DDK/WDK for which you request
@echo       a build. Whenever you set the variable explicitly, this will take
@echo       precedence over the auto-detected path!
@echo       The environment variables are as follows:
@echo.
@echo       %%NT4BASE%%  - Set this up for ^"-NT4^" builds
@echo       %%W2KBASE%%  - Set this up for ^"-W2K^" and ^"-W2K64^" builds
@echo       %%WXPBASE%%  - Set this up for ^"-WXP^", ^"-WXP64^", ^"-WXP2K^" builds
@echo       %%WNETBASE%% - Set this up for ^"-WNET*^" builds
@echo       %%WLHBASE%%  - Set this up for ^"-WLH*^" builds
@echo.
@echo       %%WDF_ROOT%% must be set if attempting to do a WDF Build previous to the
@echo       Vista WDK (in later DDKs there is no need to set WDF_ROOT).
@echo.
@echo Path to this script:
@echo      %~f0
@echo.
@echo   %OSR_VERSTR%
@echo   -^> report any problems to ^<info@osr.com^> or ^<http://assarbad.net/contact/^>
@echo.

:END
popd & endlocal & exit /b %OSR_ERRCODE%

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -