Release 961222
[wine/gsoc-2012-control.git] / misc / ntdll.c
blob7f43d32e19e217d7327882efd66c707205f5d64c
1 /*
2 * NT basis DLL
3 *
4 * Copyright 1996 Marcus Meissner
5 */
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #include <unistd.h>
11 #include <time.h>
12 #include <ctype.h>
13 #include <math.h>
14 #include "win.h"
15 #include "windows.h"
16 #include "stddebug.h"
17 #include "debug.h"
18 #include "module.h"
19 #include "xmalloc.h"
20 #include "heap.h"
22 /**************************************************************************
23 * RtlLengthRequiredSid [NTDLL]
25 DWORD
26 RtlLengthRequiredSid(DWORD nrofsubauths) {
27 return sizeof(DWORD)*nrofsubauths+sizeof(SID);
30 /**************************************************************************
31 * RtlNormalizeProcessParams [NTDLL]
33 LPVOID
34 RtlNormalizeProcessParams(LPVOID x)
36 fprintf(stdnimp,"RtlNormalizeProcessParams(%p), stub.\n",x);
37 return x;
40 /**************************************************************************
41 * RtlInitializeSid [NTDLL]
43 DWORD
44 RtlInitializeSid(LPSID lpsid,LPSID_IDENTIFIER_AUTHORITY lpsidauth,DWORD c) {
45 BYTE a = c&0xff;
47 if (a>=SID_MAX_SUB_AUTHORITIES)
48 return a;
49 lpsid->SubAuthorityCount = a;
50 lpsid->Revision = SID_REVISION;
51 memcpy(&(lpsid->IdentifierAuthority),lpsidauth,sizeof(SID_IDENTIFIER_AUTHORITY));
52 return 0;
55 /**************************************************************************
56 * RtlSubAuthoritySid [NTDLL]
58 LPDWORD
59 RtlSubAuthoritySid(LPSID lpsid,DWORD nr) {
60 return &(lpsid->SubAuthority[nr]);
63 /**************************************************************************
64 * RtlSubAuthorityCountSid [NTDLL]
66 LPBYTE
67 RtlSubAuthorityCountSid(LPSID lpsid) {
68 return ((LPBYTE)lpsid)+1;
71 /**************************************************************************
72 * RtlCopySid [NTDLL]
74 DWORD
75 RtlCopySid(DWORD len,LPSID to,LPSID from) {
76 if (len<(from->SubAuthorityCount*4+8))
77 return 0xC0000023;
78 memmove(to,from,from->SubAuthorityCount*4+8);
79 return 0;
82 /**************************************************************************
83 * RtlOemToUnicodeN [NTDLL]
85 DWORD /* NTSTATUS */
86 RtlOemToUnicodeN(LPWSTR unistr,DWORD unilen,LPDWORD reslen,LPSTR oemstr,DWORD oemlen) {
87 DWORD len;
88 LPWSTR x;
90 len = oemlen;
91 if (unilen/2 < len)
92 len = unilen/2;
93 x=(LPWSTR)xmalloc((len+1)*sizeof(WCHAR));
94 lstrcpynAtoW(x,oemstr,len+1);
95 memcpy(unistr,x,len*2);
96 if (reslen) *reslen = len*2;
97 return 0;
100 /**************************************************************************
101 * RtlUnicodeToOemN [NTDLL]
103 DWORD /* NTSTATUS */
104 RtlUnicodeToOemN(LPSTR oemstr,DWORD oemlen,LPDWORD reslen,LPWSTR unistr,DWORD unilen) {
105 DWORD len;
106 LPSTR x;
108 len = oemlen;
109 if (unilen/2 < len)
110 len = unilen/2;
111 x=(LPSTR)xmalloc(len+1);
112 lstrcpynWtoA(x,unistr,len+1);
113 memcpy(oemstr,x,len);
114 if (reslen) *reslen = len;
115 return 0;
118 /**************************************************************************
119 * RtlUnicodeStringToOemString [NTDLL]
121 DWORD /* NTSTATUS */
122 RtlUnicodeStringToOemString(LPUNICODE_STRING uni,LPANSI_STRING oem,BOOL32 alloc)
124 if (alloc) {
125 oem->Buffer = (LPSTR)xmalloc(uni->Length/2)+1;
126 oem->MaximumLength = uni->Length/2+1;
128 oem->Length = uni->Length/2;
129 lstrcpynWtoA(oem->Buffer,uni->Buffer,uni->Length/2+1);
130 return 0;