Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
2.5 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. config16.c
  5. Abstract:
  6. Remove Far East 16bit drivers from config.nt.
  7. Author:
  8. Geoffrey Guo (geoffguo) 30-Jul-2002 Created
  9. Revision History:
  10. <alias> <date> <comments>
  11. --*/
  12. #include "StdAfx.h"
  13. #include "clmt.h"
  14. char *szFEDrivers[] = {"ntfont.sys", "font_win.sys", "$disp.sys",
  15. "disp_win.sys", "kkcfunc.sys", "MSIMEK.SYS",
  16. "MSIMEI.SYS", "\0"};
  17. BOOL
  18. Remove16bitFEDrivers(void)
  19. {
  20. BOOL bRet = FALSE;
  21. HRESULT hr;
  22. FILE *pInFile, *pOutFile;
  23. DWORD i;
  24. TCHAR szFileIn[MAX_PATH];
  25. TCHAR szFileOut[MAX_PATH];
  26. char szInBuf[MAX_PATH];
  27. char szOutBuf[MAX_PATH];
  28. DPF(SHLmsg, L"Enter Remove16bitFEDrivers: ");
  29. if (!GetEnvironmentVariable(TEXT("windir"), szFileIn, MAX_PATH))
  30. goto Exit;
  31. if ( (hr = StringCchCopy(szFileOut, MAX_PATH, szFileIn)) != S_OK)
  32. goto Exit;
  33. if ((hr = StringCchCat(szFileIn, MAX_PATH, TEXT("\\system32\\config.nt"))) != S_OK)
  34. goto Exit;
  35. if ((pInFile = _wfopen(szFileIn, TEXT("r"))) == NULL)
  36. goto Exit;
  37. if ((hr = StringCchCat(szFileOut, MAX_PATH, TEXT("\\system32\\config.clm"))) != S_OK)
  38. {
  39. fclose(pInFile);
  40. goto Exit;
  41. }
  42. if ((pOutFile = _wfopen(szFileOut, TEXT("w"))) == NULL)
  43. {
  44. fclose(pInFile);
  45. goto Exit;
  46. }
  47. while (fgets(szInBuf, MAX_PATH-1, pInFile))
  48. {
  49. i = 0;
  50. szOutBuf[0] = (char)'\0';
  51. while (*(szFEDrivers[i]) != (char)'\0')
  52. {
  53. if (StrStrIA((char*)szInBuf, szFEDrivers[i]))
  54. {
  55. if ((hr = StringCchCopyA(szOutBuf, MAX_PATH, "REM ")) != S_OK)
  56. goto Exit1;
  57. if ((hr = StringCchCatA(szOutBuf, MAX_PATH, szInBuf)) != S_OK)
  58. goto Exit1;
  59. break;
  60. }
  61. i++;
  62. }
  63. if (szOutBuf[0] == (char)'\0')
  64. {
  65. if ((hr = StringCchCopyA(szOutBuf, MAX_PATH, szInBuf)) != S_OK)
  66. goto Exit1;
  67. }
  68. fputs (szOutBuf, pOutFile);
  69. }
  70. bRet = TRUE;
  71. Exit1:
  72. fclose(pOutFile);
  73. fclose(pInFile);
  74. if (bRet)
  75. {
  76. CopyFile(szFileOut, szFileIn, FALSE);
  77. DPF(SHLmsg, L"Exit Remove16bitFEDrivers:");
  78. }
  79. else
  80. DPF(SHLerr, L"Remove16bitFEDrivers: failed");
  81. DeleteFile(szFileOut);
  82. Exit:
  83. return bRet;
  84. }