mirror of
https://github.com/reactos/reactos.git
synced 2024-10-06 09:24:11 +00:00
b2494542da
From releases/0.4.9 to releases/0.4.10 we introduced tons of compiler warnings within the whole host-tools component although the 'offending' code did not change in between both. I am not aware which commit unhid them exactly during 0.4.10-dev', but I will follow the footsteps of master with the fixes. releases/0.4.9 still had 0 warnings within host-tools, and releases/0.4.13 managed to achieve the same again! fix is a pick from: 0.4.11-dev-436-gda019b0fc5
(the mkhive\registry.c part) 0.4.13-dev-132-gf47f45dbdd
(picked the remaining parts of that) 0.4.13-dev-133-gc02257ef57
0.4.13-dev-134-g2c11c41115
the warnings could be observed with MSVC 2010SP1 (16.0.40219.1) x86 target in dbg configuration: where the 0.4.13-dev-132-gf47f45dbdd
part fixed the: [6/12736] Performing build step for 'host-tools' [13/250] Building CXX object sdk\tools\hhpcomp\CMakeFiles\hhpcomp.dir\hhpcomp.cpp.obj C:\0410rls\reactos\sdk\tools\hhpcomp\hhpcomp.cpp(59) : warning C4996: 'chdir': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _chdir. See online help for details. C:\VS2010_SP1\VC\INCLUDE\direct.h(123) : see declaration of 'chdir' C:\0410rls\reactos\sdk\tools\hhpcomp\chmc\chmc.c(160) : warning C4996: 'fileno': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fileno. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(723) : see declaration of 'fileno' C:\0410rls\reactos\sdk\tools\hhpcomp\chmc\chmc.c(447) : warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details. C:\VS2010_SP1\VC\INCLUDE\string.h(238) : see declaration of 'strdup' C:\0410rls\reactos\sdk\tools\hhpcomp\chmc\chmc.c(476) : warning C4996: 'fileno': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fileno. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(723) : see declaration of 'fileno' C:\0410rls\reactos\sdk\tools\hhpcomp\chmc\chmc.c(511) : warning C4996: 'unlink': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _unlink. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(299) : see declaration of 'unlink' C:\0410rls\reactos\sdk\tools\hpp\hpp.c(44) : warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details. C:\VS2010_SP1\VC\INCLUDE\string.h(238) : see declaration of 'strdup' C:\0410rls\reactos\sdk\tools\isohybrid\isohybrid.c(1201) : warning C4996: 'fileno': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fileno. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(723) : see declaration of 'fileno' C:\0410rls\reactos\sdk\tools\isohybrid\isohybrid.c(1204) : warning C4996: 'fileno': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fileno. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(723) : see declaration of 'fileno' C:\0410rls\reactos\sdk\tools\kbdtool\parser.c(448) : warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details. C:\VS2010_SP1\VC\INCLUDE\string.h(238) : see declaration of 'strdup' C:\0410rls\reactos\sdk\tools\kbdtool\parser.c(523) : warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details. C:\VS2010_SP1\VC\INCLUDE\string.h(238) : see declaration of 'strdup' C:\0410rls\reactos\sdk\tools\kbdtool\parser.c(598) : warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details. C:\VS2010_SP1\VC\INCLUDE\string.h(238) : see declaration of 'strdup' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\libschily\stdio\ffileread.c(30) : warning C4996: 'fileno': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fileno. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(723) : see declaration of 'fileno' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\libschily\stdio\fcons.c(62) : warning C4996: 'fdopen': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fdopen. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(721) : see declaration of 'fdopen' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\libschily\stdio\flag.c(44) : warning C4996: 'fileno': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fileno. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(723) : see declaration of 'fileno' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\libschily\stdio\flag.c(73) : warning C4996: 'fileno': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fileno. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(723) : see declaration of 'fileno' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\libschily\stdio\flag.c(98) : warning C4996: 'fileno': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fileno. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(723) : see declaration of 'fileno' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\libschily\stdio\filewrite.c(82) : warning C4996: 'fileno': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fileno. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(723) : see declaration of 'fileno' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\libschily\fconv.c(231) : warning C4996: 'ecvt': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _ecvt. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdlib.h(864) : see declaration of 'ecvt' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\libschily\fconv.c(320) : warning C4996: 'fcvt': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fcvt. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdlib.h(865) : see declaration of 'fcvt' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\libschily\format.c(745) : warning C4996: 'gcvt': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _gcvt. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdlib.h(866) : see declaration of 'gcvt' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\libschily\searchinpath.c(221) : warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details. C:\VS2010_SP1\VC\INCLUDE\string.h(238) : see declaration of 'strdup' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\libsiconv\sic_nls.c(450) : warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details. C:\VS2010_SP1\VC\INCLUDE\string.h(238) : see declaration of 'strdup' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\boot.c(169) : warning C4996: 'access': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _access. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(299) : see declaration of 'access' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\boot.c(225) : warning C4996: 'access': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _access. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(299) : see declaration of 'access' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\boot.c(414) : warning C4996: 'open': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _open. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(312) : see declaration of 'open' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\boot.c(420) : warning C4996: 'read': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _read. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(313) : see declaration of 'read' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\boot.c(425) : warning C4996: 'close': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _close. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(302) : see declaration of 'close' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\boot.c(464) : warning C4996: 'open': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _open. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(312) : see declaration of 'open' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\boot.c(467) : warning C4996: 'read': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _read. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(313) : see declaration of 'read' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\boot.c(469) : warning C4996: 'close': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _close. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(302) : see declaration of 'close' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\boot.c(536) : warning C4996: 'open': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _open. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(312) : see declaration of 'open' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\boot.c(541) : warning C4996: 'read': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _read. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(313) : see declaration of 'read' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\boot.c(549) : warning C4996: 'close': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _close. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(302) : see declaration of 'close' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\eltorito.c(447) : warning C4996: 'open': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _open. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(312) : see declaration of 'open' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\eltorito.c(453) : warning C4996: 'read': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _read. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(313) : see declaration of 'read' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\eltorito.c(457) : warning C4996: 'close': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _close. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(302) : see declaration of 'close' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\eltorito.c(585) : warning C4996: 'open': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _open. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(312) : see declaration of 'open' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\eltorito.c(594) : warning C4996: 'read': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _read. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(313) : see declaration of 'read' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\eltorito.c(615) : warning C4996: 'lseek': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _lseek. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(310) : see declaration of 'lseek' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\eltorito.c(623) : warning C4996: 'write': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _write. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(318) : see declaration of 'write' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\eltorito.c(624) : warning C4996: 'close': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _close. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(302) : see declaration of 'close' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\match.c(74) : warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details. C:\VS2010_SP1\VC\INCLUDE\string.h(238) : see declaration of 'strdup' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\match.c(201) : warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details. C:\VS2010_SP1\VC\INCLUDE\string.h(238) : see declaration of 'strdup' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\multi.c(124) : warning C4996: 'fileno': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fileno. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(723) : see declaration of 'fileno' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\multi.c(126) : warning C4996: 'lseek': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _lseek. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(310) : see declaration of 'lseek' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\multi.c(130) : warning C4996: 'read': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _read. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(313) : see declaration of 'read' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\multi.c(124) : warning C4996: 'fileno': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fileno. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(723) : see declaration of 'fileno' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\multi.c(126) : warning C4996: 'lseek': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _lseek. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(310) : see declaration of 'lseek' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\multi.c(130) : warning C4996: 'read': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _read. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(313) : see declaration of 'read' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\tree.c(1628) : warning C4996: 'access': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _access. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(299) : see declaration of 'access' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\write.c(204) : warning C4996: 'unlink': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _unlink. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(299) : see declaration of 'unlink' C:\0410rls\reactos\sdk\tools\wpp\preproc.c(162) : warning C4013: 'open' undefined; assuming extern returning int C:\0410rls\reactos\sdk\tools\wpp\preproc.c(165) : warning C4013: 'close' undefined; assuming extern returning int C:\0410rls\reactos\sdk\tools\widl\widl.c(863) : warning C4996: 'fdopen': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fdopen. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(721) : see declaration of 'fdopen' C:\0410rls\reactos\sdk\tools\widl\widl.c(910) : warning C4996: 'unlink': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _unlink. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(299) : see declaration of 'unlink' C:\0410rls\reactos\sdk\tools\widl\widl.c(912) : warning C4996: 'unlink': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _unlink. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(299) : see declaration of 'unlink' C:\0410rls\reactos\sdk\tools\widl\widl.c(914) : warning C4996: 'unlink': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _unlink. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(299) : see declaration of 'unlink' C:\0410rls\reactos\sdk\tools\widl\widl.c(916) : warning C4996: 'unlink': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _unlink. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(299) : see declaration of 'unlink' C:\0410rls\reactos\sdk\tools\widl\widl.c(918) : warning C4996: 'unlink': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _unlink. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(299) : see declaration of 'unlink' C:\0410rls\reactos\sdk\tools\widl\widl.c(920) : warning C4996: 'unlink': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _unlink. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(299) : see declaration of 'unlink' C:\0410rls\reactos\sdk\tools\widl\widl.c(922) : warning C4996: 'unlink': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _unlink. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(299) : see declaration of 'unlink' C:\0410rls\reactos\sdk\tools\widl\widl.c(924) : warning C4996: 'unlink': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _unlink. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(299) : see declaration of 'unlink' C:\0410rls\reactos\sdk\tools\widl\widl.c(926) : warning C4996: 'unlink': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _unlink. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(299) : see declaration of 'unlink' C:\0410rls\reactos\sdk\tools\widl\typelib.c(264) : warning C4013: 'read' undefined; assuming extern returning int C:\0410rls\reactos\sdk\tools\widl\typelib.c(270) : warning C4013: 'lseek' undefined; assuming extern returning int C:\0410rls\reactos\sdk\tools\widl\typelib.c(343) : warning C4013: 'open' undefined; assuming extern returning int C:\0410rls\reactos\sdk\tools\widl\typelib.c(383) : warning C4013: 'close' undefined; assuming extern returning int C:\0410rls\reactos\sdk\tools\widl\utils.c(281) : warning C4013: 'open' undefined; assuming extern returning int C:\0410rls\reactos\sdk\tools\widl\utils.c(283) : warning C4013: 'write' undefined; assuming extern returning int C:\0410rls\reactos\sdk\tools\widl\utils.c(285) : warning C4013: 'close' undefined; assuming extern returning int [194/250] Building C object sdk\tools\widl\CMakeFiles\widl.dir\parser.yy.c.obj parser.l(488) : warning C4996: 'unlink': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _unlink. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(299) : see declaration of 'unlink' parser.l(542) : warning C4996: 'fdopen': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fdopen. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(721) : see declaration of 'fdopen' parser.l(562) : warning C4996: 'unlink': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _unlink. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(299) : see declaration of 'unlink' [197/250] Building C object sdk\tools\widl\CMakeFiles\widl.dir\parser.tab.c.obj parser.y(454) : warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details. C:\VS2010_SP1\VC\INCLUDE\string.h(238) : see declaration of 'strdup' ... and so on ... too many to name them all ---------- 0.4.13-dev-134-g2c11c41115
part fixed the: C:\0410rls\reactos\sdk\tools\widl\getopt.c(233) : warning C4013: '_getopt_internal' undefined; assuming extern returning int ---------- 0.4.13-dev-133-gc02257ef57
part fixed the: C:\0410rls\reactos\sdk\tools\isohybrid\isohybrid.c(978) : warning C4101: 'orig_gpt_size' : unreferenced local variable C:\0410rls\reactos\sdk\tools\isohybrid\isohybrid.c(978) : warning C4101: 'gpt_size' : unreferenced local variable ---------- partial port (registry.c) of 0.4.11-dev-436-gda019b0fc5
fixed the: C:\0410rls\reactos\sdk\tools\mkhive\registry.c(369) : warning C4101: 'SubKeyCell' : unreferenced local variable
512 lines
14 KiB
C
512 lines
14 KiB
C
/*
|
|
* ReactOS kernel
|
|
* Copyright (C) 2003, 2006 ReactOS Team
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
*/
|
|
/*
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
* PROJECT: ReactOS hive maker
|
|
* FILE: tools/mkhive/reginf.c
|
|
* PURPOSE: Inf file import code
|
|
* PROGRAMMERS: Eric Kohl
|
|
* Hervé Poussineau
|
|
*/
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
|
|
#define NDEBUG
|
|
#include "mkhive.h"
|
|
|
|
#define FLG_ADDREG_BINVALUETYPE 0x00000001
|
|
#define FLG_ADDREG_NOCLOBBER 0x00000002
|
|
#define FLG_ADDREG_DELVAL 0x00000004
|
|
#define FLG_ADDREG_APPEND 0x00000008
|
|
#define FLG_ADDREG_KEYONLY 0x00000010
|
|
#define FLG_ADDREG_OVERWRITEONLY 0x00000020
|
|
#define FLG_ADDREG_TYPE_SZ 0x00000000
|
|
#define FLG_ADDREG_TYPE_MULTI_SZ 0x00010000
|
|
#define FLG_ADDREG_TYPE_EXPAND_SZ 0x00020000
|
|
#define FLG_ADDREG_TYPE_BINARY (0x00000000 | FLG_ADDREG_BINVALUETYPE)
|
|
#define FLG_ADDREG_TYPE_DWORD (0x00010000 | FLG_ADDREG_BINVALUETYPE)
|
|
#define FLG_ADDREG_TYPE_NONE (0x00020000 | FLG_ADDREG_BINVALUETYPE)
|
|
#define FLG_ADDREG_TYPE_MASK (0xFFFF0000 | FLG_ADDREG_BINVALUETYPE)
|
|
|
|
|
|
static const WCHAR HKCR[] = {'H','K','C','R',0};
|
|
static const WCHAR HKCU[] = {'H','K','C','U',0};
|
|
static const WCHAR HKLM[] = {'H','K','L','M',0};
|
|
static const WCHAR HKU[] = {'H','K','U',0};
|
|
static const WCHAR HKR[] = {'H','K','R',0};
|
|
static const WCHAR BCD[] = {'B','C','D',0};
|
|
|
|
static const WCHAR HKCRPath[] = {'\\','R','e','g','i','s','t','r','y','\\','M','a','c','h','i','n','e','\\','S','O','F','T','W','A','R','E','\\','C','l','a','s','s','e','s','\\',0};
|
|
static const WCHAR HKCUPath[] = {'\\','R','e','g','i','s','t','r','y','\\','U','s','e','r','\\','.','D','E','F','A','U','L','T','\\',0};
|
|
static const WCHAR HKLMPath[] = {'\\','R','e','g','i','s','t','r','y','\\','M','a','c','h','i','n','e','\\',0};
|
|
static const WCHAR HKUPath[] = {'\\','R','e','g','i','s','t','r','y','\\','U','s','e','r','\\',0};
|
|
static const WCHAR BCDPath[] = {'\\','R','e','g','i','s','t','r','y','\\','M','a','c','h','i','n','e','\\',0};
|
|
|
|
static const WCHAR AddReg[] = {'A','d','d','R','e','g',0};
|
|
static const WCHAR DelReg[] = {'D','e','l','R','e','g',0};
|
|
|
|
/* FUNCTIONS ****************************************************************/
|
|
|
|
static BOOL
|
|
get_root_key(PWCHAR Name)
|
|
{
|
|
if (!strcmpiW(Name, HKCR))
|
|
{
|
|
strcpyW(Name, HKCRPath);
|
|
return TRUE;
|
|
}
|
|
|
|
if (!strcmpiW(Name, HKCU))
|
|
{
|
|
strcpyW(Name, HKCUPath);
|
|
return TRUE;
|
|
}
|
|
|
|
if (!strcmpiW(Name, HKLM))
|
|
{
|
|
strcpyW(Name, HKLMPath);
|
|
return TRUE;
|
|
}
|
|
|
|
if (!strcmpiW(Name, HKU))
|
|
{
|
|
strcpyW(Name, HKUPath);
|
|
return TRUE;
|
|
}
|
|
|
|
if (!strcmpiW(Name, BCD))
|
|
{
|
|
strcpyW(Name, BCDPath);
|
|
return TRUE;
|
|
}
|
|
|
|
#if 0
|
|
if (!strcmpiW(Name, HKR))
|
|
return FALSE;
|
|
#endif
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* append_multi_sz_value
|
|
*
|
|
* Append a multisz string to a multisz registry value.
|
|
*/
|
|
// NOTE: Synced with setupapi/install.c ; see also usetup/registry.c
|
|
static VOID
|
|
append_multi_sz_value(
|
|
IN HKEY KeyHandle,
|
|
IN PWCHAR ValueName,
|
|
IN PWCHAR Strings,
|
|
IN ULONG StringSize) // In characters
|
|
{
|
|
ULONG Size, Total; // In bytes
|
|
ULONG Type;
|
|
PWCHAR Buffer;
|
|
PWCHAR p;
|
|
size_t len;
|
|
LONG Error;
|
|
|
|
Error = RegQueryValueExW(KeyHandle,
|
|
ValueName,
|
|
NULL,
|
|
&Type,
|
|
NULL,
|
|
&Size);
|
|
if ((Error != ERROR_SUCCESS) || (Type != REG_MULTI_SZ))
|
|
return;
|
|
|
|
Buffer = malloc(Size + StringSize * sizeof(WCHAR));
|
|
if (Buffer == NULL)
|
|
return;
|
|
|
|
Error = RegQueryValueExW(KeyHandle,
|
|
ValueName,
|
|
NULL,
|
|
NULL,
|
|
(PUCHAR)Buffer,
|
|
&Size);
|
|
if (Error != ERROR_SUCCESS)
|
|
goto done;
|
|
|
|
/* compare each string against all the existing ones */
|
|
Total = Size;
|
|
while (*Strings != 0)
|
|
{
|
|
len = strlenW(Strings) + 1;
|
|
|
|
for (p = Buffer; *p != 0; p += strlenW(p) + 1)
|
|
if (!strcmpiW(p, Strings))
|
|
break;
|
|
|
|
if (*p == 0) /* not found, need to append it */
|
|
{
|
|
memcpy(p, Strings, len * sizeof(WCHAR));
|
|
p[len] = 0;
|
|
Total += len * sizeof(WCHAR);
|
|
}
|
|
Strings += len;
|
|
}
|
|
|
|
if (Total != Size)
|
|
{
|
|
DPRINT("setting value %S to %S\n", ValueName, Buffer);
|
|
RegSetValueExW(KeyHandle,
|
|
ValueName,
|
|
0,
|
|
REG_MULTI_SZ,
|
|
(PUCHAR)Buffer,
|
|
Total + sizeof(WCHAR));
|
|
}
|
|
|
|
done:
|
|
free(Buffer);
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* do_reg_operation
|
|
*
|
|
* Perform an add/delete registry operation depending on the flags.
|
|
*/
|
|
static BOOL
|
|
do_reg_operation(
|
|
IN HKEY KeyHandle,
|
|
IN PWCHAR ValueName,
|
|
IN PINFCONTEXT Context,
|
|
IN ULONG Flags)
|
|
{
|
|
WCHAR EmptyStr = 0;
|
|
ULONG Type;
|
|
ULONG Size;
|
|
LONG Error;
|
|
|
|
if (Flags & FLG_ADDREG_DELVAL) /* deletion */
|
|
{
|
|
if (ValueName)
|
|
{
|
|
RegDeleteValueW(KeyHandle, ValueName);
|
|
}
|
|
else
|
|
{
|
|
RegDeleteKeyW(KeyHandle, NULL);
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
if (Flags & FLG_ADDREG_KEYONLY)
|
|
return TRUE;
|
|
|
|
if (Flags & (FLG_ADDREG_NOCLOBBER | FLG_ADDREG_OVERWRITEONLY))
|
|
{
|
|
Error = RegQueryValueExW(KeyHandle,
|
|
ValueName,
|
|
NULL,
|
|
NULL,
|
|
NULL,
|
|
NULL);
|
|
if ((Error == ERROR_SUCCESS) && (Flags & FLG_ADDREG_NOCLOBBER))
|
|
return TRUE;
|
|
|
|
if ((Error != ERROR_SUCCESS) && (Flags & FLG_ADDREG_OVERWRITEONLY))
|
|
return TRUE;
|
|
}
|
|
|
|
switch (Flags & FLG_ADDREG_TYPE_MASK)
|
|
{
|
|
case FLG_ADDREG_TYPE_SZ:
|
|
Type = REG_SZ;
|
|
break;
|
|
|
|
case FLG_ADDREG_TYPE_MULTI_SZ:
|
|
Type = REG_MULTI_SZ;
|
|
break;
|
|
|
|
case FLG_ADDREG_TYPE_EXPAND_SZ:
|
|
Type = REG_EXPAND_SZ;
|
|
break;
|
|
|
|
case FLG_ADDREG_TYPE_BINARY:
|
|
Type = REG_BINARY;
|
|
break;
|
|
|
|
case FLG_ADDREG_TYPE_DWORD:
|
|
Type = REG_DWORD;
|
|
break;
|
|
|
|
case FLG_ADDREG_TYPE_NONE:
|
|
Type = REG_NONE;
|
|
break;
|
|
|
|
default:
|
|
Type = Flags >> 16;
|
|
break;
|
|
}
|
|
|
|
if (!(Flags & FLG_ADDREG_BINVALUETYPE) ||
|
|
(Type == REG_DWORD && InfHostGetFieldCount(Context) == 5))
|
|
{
|
|
PWCHAR Str = NULL;
|
|
|
|
if (Type == REG_MULTI_SZ)
|
|
{
|
|
if (InfHostGetMultiSzField(Context, 5, NULL, 0, &Size) != 0)
|
|
Size = 0;
|
|
|
|
if (Size)
|
|
{
|
|
Str = malloc(Size * sizeof(WCHAR));
|
|
if (Str == NULL)
|
|
return FALSE;
|
|
|
|
InfHostGetMultiSzField(Context, 5, Str, Size, NULL);
|
|
}
|
|
|
|
if (Flags & FLG_ADDREG_APPEND)
|
|
{
|
|
if (Str == NULL)
|
|
return TRUE;
|
|
|
|
append_multi_sz_value(KeyHandle,
|
|
ValueName,
|
|
Str,
|
|
Size);
|
|
|
|
free(Str);
|
|
return TRUE;
|
|
}
|
|
/* else fall through to normal string handling */
|
|
}
|
|
else
|
|
{
|
|
if (InfHostGetStringField(Context, 5, NULL, 0, &Size) != 0)
|
|
Size = 0;
|
|
|
|
if (Size)
|
|
{
|
|
Str = malloc(Size * sizeof(WCHAR));
|
|
if (Str == NULL)
|
|
return FALSE;
|
|
|
|
InfHostGetStringField(Context, 5, Str, Size, NULL);
|
|
}
|
|
}
|
|
|
|
if (Type == REG_DWORD)
|
|
{
|
|
ULONG dw = Str ? strtoulW(Str, NULL, 0) : 0;
|
|
|
|
DPRINT("setting dword %S to %x\n", ValueName, dw);
|
|
|
|
RegSetValueExW(KeyHandle,
|
|
ValueName,
|
|
0,
|
|
Type,
|
|
(const PUCHAR)&dw,
|
|
sizeof(ULONG));
|
|
}
|
|
else
|
|
{
|
|
DPRINT("setting value %S to %S\n", ValueName, Str);
|
|
|
|
if (Str)
|
|
{
|
|
RegSetValueExW(KeyHandle,
|
|
ValueName,
|
|
0,
|
|
Type,
|
|
(PVOID)Str,
|
|
(ULONG)(Size * sizeof(WCHAR)));
|
|
}
|
|
else
|
|
{
|
|
RegSetValueExW(KeyHandle,
|
|
ValueName,
|
|
0,
|
|
Type,
|
|
(PVOID)&EmptyStr,
|
|
sizeof(WCHAR));
|
|
}
|
|
}
|
|
free(Str);
|
|
}
|
|
else /* get the binary data */
|
|
{
|
|
PUCHAR Data = NULL;
|
|
|
|
if (InfHostGetBinaryField(Context, 5, NULL, 0, &Size) != 0)
|
|
Size = 0;
|
|
|
|
if (Size)
|
|
{
|
|
Data = malloc(Size);
|
|
if (Data == NULL)
|
|
return FALSE;
|
|
|
|
DPRINT("setting binary data '%S' len %d\n", ValueName, (ULONG)Size);
|
|
InfHostGetBinaryField(Context, 5, Data, Size, NULL);
|
|
}
|
|
|
|
RegSetValueExW(KeyHandle,
|
|
ValueName,
|
|
0,
|
|
Type,
|
|
(PVOID)Data,
|
|
(ULONG)Size);
|
|
|
|
free(Data);
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
/***********************************************************************
|
|
* registry_callback
|
|
*
|
|
* Called once for each AddReg and DelReg entry in a given section.
|
|
*/
|
|
static BOOL
|
|
registry_callback(HINF hInf, PWCHAR Section, BOOL Delete)
|
|
{
|
|
WCHAR Buffer[MAX_INF_STRING_LENGTH];
|
|
PWCHAR ValuePtr;
|
|
ULONG Flags;
|
|
size_t Length;
|
|
|
|
PINFCONTEXT Context = NULL;
|
|
HKEY KeyHandle;
|
|
BOOL Ok;
|
|
|
|
|
|
Ok = InfHostFindFirstLine(hInf, Section, NULL, &Context) == 0;
|
|
if (!Ok)
|
|
return TRUE; /* Don't fail if the section isn't present */
|
|
|
|
for (;Ok; Ok = (InfHostFindNextLine(Context, Context) == 0))
|
|
{
|
|
/* get root */
|
|
if (InfHostGetStringField(Context, 1, Buffer, sizeof(Buffer)/sizeof(WCHAR), NULL) != 0)
|
|
continue;
|
|
if (!get_root_key(Buffer))
|
|
continue;
|
|
|
|
/* get key */
|
|
Length = strlenW(Buffer);
|
|
if (InfHostGetStringField(Context, 2, Buffer + Length, sizeof(Buffer)/sizeof(WCHAR) - (ULONG)Length, NULL) != 0)
|
|
*Buffer = 0;
|
|
|
|
DPRINT("KeyName: <%S>\n", Buffer);
|
|
|
|
if (Delete)
|
|
{
|
|
Flags = FLG_ADDREG_DELVAL;
|
|
}
|
|
else
|
|
{
|
|
/* get flags */
|
|
if (InfHostGetIntField(Context, 4, (INT *)&Flags) != 0)
|
|
Flags = 0;
|
|
}
|
|
|
|
DPRINT("Flags: 0x%x\n", Flags);
|
|
|
|
if (Delete || (Flags & FLG_ADDREG_OVERWRITEONLY))
|
|
{
|
|
if (RegOpenKeyW(NULL, Buffer, &KeyHandle) != ERROR_SUCCESS)
|
|
{
|
|
DPRINT("RegOpenKey(%S) failed\n", Buffer);
|
|
continue; /* ignore if it doesn't exist */
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (RegCreateKeyW(NULL, Buffer, &KeyHandle) != ERROR_SUCCESS)
|
|
{
|
|
DPRINT("RegCreateKey(%S) failed\n", Buffer);
|
|
continue;
|
|
}
|
|
}
|
|
|
|
/* get value name */
|
|
if (InfHostGetStringField(Context, 3, Buffer, sizeof(Buffer)/sizeof(WCHAR), NULL) == 0)
|
|
{
|
|
ValuePtr = Buffer;
|
|
}
|
|
else
|
|
{
|
|
ValuePtr = NULL;
|
|
}
|
|
|
|
/* and now do it */
|
|
if (!do_reg_operation(KeyHandle, ValuePtr, Context, Flags))
|
|
{
|
|
RegCloseKey(KeyHandle);
|
|
return FALSE;
|
|
}
|
|
|
|
RegCloseKey(KeyHandle);
|
|
}
|
|
|
|
InfHostFreeContext(Context);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
BOOL
|
|
ImportRegistryFile(PCHAR FileName)
|
|
{
|
|
HINF hInf;
|
|
ULONG ErrorLine;
|
|
|
|
/* Load inf file from install media. */
|
|
if (InfHostOpenFile(&hInf, FileName, 0, &ErrorLine) != 0)
|
|
{
|
|
DPRINT1("InfHostOpenFile(%s) failed\n", FileName);
|
|
return FALSE;
|
|
}
|
|
|
|
if (!registry_callback(hInf, (PWCHAR)DelReg, TRUE))
|
|
{
|
|
DPRINT1("registry_callback() for DelReg failed\n");
|
|
InfHostCloseFile(hInf);
|
|
return FALSE;
|
|
}
|
|
|
|
if (!registry_callback(hInf, (PWCHAR)AddReg, FALSE))
|
|
{
|
|
DPRINT1("registry_callback() for AddReg failed\n");
|
|
InfHostCloseFile(hInf);
|
|
return FALSE;
|
|
}
|
|
|
|
InfHostCloseFile(hInf);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
/* EOF */
|