00039 {
00040
NTSTATUS Status;
00041 OBJECT_ATTRIBUTES
ObjectAttributes;
00042 UNICODE_STRING
KeyName;
00043 UNICODE_STRING LinkName;
00044 UNICODE_STRING NullName;
00045 ANSI_STRING AnsiKeyName;
00046 ANSI_STRING AnsiLinkName;
00047 HANDLE KeyHandle;
00048
00049
00050
00051
00052
00053
if (argc != 3) {
00054 printf(
"Usage: %s <KeyPath> <SymLink>\n",argv[0]);
00055
exit(1);
00056 }
00057
00058
RtlInitAnsiString(&AnsiKeyName, argv[1]);
00059
Status =
RtlAnsiStringToUnicodeString(&KeyName, &AnsiKeyName, TRUE);
00060
if (!
NT_SUCCESS(Status)) {
00061 printf(
"RtlAnsiStringToUnicodeString failed %lx\n",Status);
00062
exit(1);
00063 }
00064
00065
RtlInitAnsiString(&AnsiLinkName, argv[2]);
00066
Status =
RtlAnsiStringToUnicodeString(&LinkName, &AnsiLinkName, TRUE);
00067
if (!
NT_SUCCESS(Status)) {
00068 printf(
"RtlAnsiStringToUnicodeString failed %lx\n",Status);
00069
exit(1);
00070 }
00071
00072 printf(
"rtsetsec: starting\n");
00073
00074
00075
00076
00077
00078 InitializeObjectAttributes(
00079 &ObjectAttributes,
00080 &KeyName,
00081 OBJ_CASE_INSENSITIVE,
00082 (HANDLE)NULL,
00083 NULL
00084 );
00085
00086
Status =
NtCreateKey(&KeyHandle,
00087 KEY_READ | KEY_WRITE,
00088 &ObjectAttributes,
00089 0,
00090 NULL,
00091 0,
00092 NULL);
00093
if (!
NT_SUCCESS(Status)) {
00094 printf(
"rtsymlnk: NtCreateKey failed: %08lx\n", Status);
00095
exit(1);
00096 }
00097
00098 NullName.Length = NullName.MaximumLength = 0;
00099 NullName.Buffer =
NULL;
00100
00101
Status =
NtSetValueKey(KeyHandle,
00102 &NullName,
00103 0,
00104 REG_LINK,
00105 LinkName.Buffer,
00106 LinkName.Length);
00107
if (!
NT_SUCCESS(Status)) {
00108 printf(
"rtsymlnk: NtSetValueKey failed: %08lx\n",Status);
00109
exit(1);
00110 }
00111
00112
Status =
NtClose(KeyHandle);
00113
if (!
NT_SUCCESS(Status)) {
00114 printf(
"rtsymlnk: NtClose failed: %08lx\n", Status);
00115
exit(1);
00116 }
00117
00118 printf(
"rtsymlnk: successful\n");
00119 }