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.

106 lines
3.4 KiB

  1. #include "stdinc.h"
  2. #pragma hdrstop
  3. #include "sxsservice.h"
  4. #include "stdlib.h"
  5. #include "stdio.h"
  6. EXTERN_C RPC_IF_HANDLE SxsStoreManager_ClientIfHandle;
  7. //
  8. // In the client, we parse the commandline, get a connection to the server, and
  9. // go to town. We implement some things like recursive directory walking ourselves,
  10. // because the server knows nothing more than "where a manifest is" and what installation
  11. // reference to use when installing it.
  12. //
  13. RPC_STATUS __cdecl wmain(INT argc, PWSTR argv[])
  14. {
  15. PWSTR pcwszUuid = NULL;
  16. PWSTR pcwszProtocolSequence = L"ncacn_np";
  17. PWSTR pcwszNetworkAddress = NULL;
  18. PWSTR pcwszEndpoint = SXS_STORE_SERVICE_NAME;
  19. PWSTR pcwszOptions = NULL;
  20. PWSTR pcwszBindingString = NULL;
  21. handle_t BindingHandle;
  22. RPC_STATUS status;
  23. SXS_INSTALL_DATA InstallData = {0};
  24. SXS_INSTALL_RESULT InstallResult;
  25. for (INT i = 1; i < argc; i++) {
  26. PCWSTR arg = argv[i];
  27. if (lstrcmpiW(arg, L"-rpcuuid") == 0) {
  28. pcwszUuid = argv[++i];
  29. }
  30. else if (lstrcmpiW(arg, L"-rpcprotocol") == 0) {
  31. pcwszProtocolSequence = argv[++i];
  32. }
  33. else if (lstrcmpiW(arg, L"-rpcaddress") == 0) {
  34. pcwszNetworkAddress = argv[++i];
  35. }
  36. else if (lstrcmpiW(arg, L"-rpcendpoint") == 0) {
  37. pcwszEndpoint = argv[++i];
  38. }
  39. else if (lstrcmpiW(arg, L"-rpcoptions") == 0) {
  40. pcwszOptions = argv[++i];
  41. }
  42. else if (lstrcmpiW(arg, L"-storeid") == 0) {
  43. UNICODE_STRING us;
  44. RtlInitUnicodeString(&us, argv[++i]);
  45. if (!NT_SUCCESS(RtlGUIDFromString(&us, &InstallData.StoreIdentifier))) {
  46. wprintf(L"Unable to convert store id %wZ to a guid.\n", &us);
  47. return ERROR_INVALID_PARAMETER;
  48. }
  49. }
  50. else if (lstrcmpiW(arg, L"-manifestpath") == 0) {
  51. InstallData.pcwszManifestPath = argv[++i];
  52. }
  53. else if (lstrcmpiW(arg, L"-reftype") == 0) {
  54. UNICODE_STRING us;
  55. RtlInitUnicodeString(&us, argv[++i]);
  56. if (!NT_SUCCESS(RtlGUIDFromString(&us, &InstallData.AssemblyReference.InstallationReferenceType))) {
  57. wprintf(L"Unable to convert reference type %wZ to a guid.\n", &us);
  58. return ERROR_INVALID_PARAMETER;
  59. }
  60. }
  61. else if (lstrcmpiW(arg, L"-refdata") == 0) {
  62. InstallData.AssemblyReference.pcwszReferenceData = argv[++i];
  63. }
  64. else if (lstrcmpiW(arg, L"-refsubdata") == 0) {
  65. InstallData.AssemblyReference.pcwszReferenceSubData = argv[++i];
  66. }
  67. }
  68. status = RpcStringBindingComposeW(
  69. pcwszUuid,
  70. pcwszProtocolSequence,
  71. pcwszNetworkAddress,
  72. pcwszEndpoint,
  73. pcwszOptions,
  74. &pcwszBindingString);
  75. if (status != RPC_S_OK) {
  76. return status;
  77. }
  78. status = RpcBindingFromStringBindingW(pcwszBindingString, &BindingHandle);
  79. RpcStringFreeW(&pcwszBindingString);
  80. if (status != RPC_S_OK) {
  81. return status;
  82. }
  83. if (!SxsProtectedInstall(
  84. BindingHandle,
  85. 0,
  86. 1,
  87. &InstallData,
  88. &InstallResult))
  89. {
  90. wprintf(L"Installation failed - lasterror = 0x%08lx (%ld)\n", ::GetLastError(), ::GetLastError());
  91. }
  92. else {
  93. wprintf(L"Installation succeeded - disposition %d\n", InstallResult);
  94. }
  95. }