Do not overwrite the valid ObjectAttributes->RootDirectory.
[wine.git] / win32 / newfns.c
blob86bc23a1550f8415a35bf1e148ccaf70de8f7fca
1 /*
2 * Win32 miscellaneous functions
4 * Copyright 1995 Thomas Sandford (tdgsandf@prds-grn.demon.co.uk)
5 */
7 /* Misc. new functions - they should be moved into appropriate files
8 at a later date. */
10 #include <string.h>
11 #include <sys/time.h>
12 #include <unistd.h>
13 #include "windef.h"
14 #include "winerror.h"
15 #include "heap.h"
16 #include "debugtools.h"
18 DEFAULT_DEBUG_CHANNEL(win32);
19 DECLARE_DEBUG_CHANNEL(debug);
22 /****************************************************************************
23 * QueryPerformanceCounter (KERNEL32.564)
25 BOOL WINAPI QueryPerformanceCounter(PLARGE_INTEGER counter)
27 struct timeval tv;
29 gettimeofday(&tv,NULL);
30 counter->s.LowPart = tv.tv_usec+tv.tv_sec*1000000;
31 counter->s.HighPart = 0;
32 return TRUE;
35 /****************************************************************************
36 * QueryPerformanceFrequency (KERNEL32.565)
38 BOOL WINAPI QueryPerformanceFrequency(PLARGE_INTEGER frequency)
40 frequency->s.LowPart = 1000000;
41 frequency->s.HighPart = 0;
42 return TRUE;
45 /****************************************************************************
46 * FlushInstructionCache (KERNEL32.261)
48 BOOL WINAPI FlushInstructionCache(DWORD x,DWORD y,DWORD z) {
49 FIXME_(debug)("(0x%08lx,0x%08lx,0x%08lx): stub\n",x,y,z);
50 return TRUE;
53 /***********************************************************************
54 * CreateNamedPipeA (KERNEL32.168)
56 HANDLE WINAPI CreateNamedPipeA (LPCSTR lpName, DWORD dwOpenMode,
57 DWORD dwPipeMode, DWORD nMaxInstances,
58 DWORD nOutBufferSize, DWORD nInBufferSize,
59 DWORD nDefaultTimeOut,
60 LPSECURITY_ATTRIBUTES lpSecurityAttributes)
62 FIXME("(Name=%s, OpenMode=%#08lx, dwPipeMode=%#08lx, MaxInst=%ld, OutBSize=%ld, InBuffSize=%ld, DefTimeOut=%ld, SecAttr=%p): stub\n",
63 debugstr_a(lpName), dwOpenMode, dwPipeMode, nMaxInstances,
64 nOutBufferSize, nInBufferSize, nDefaultTimeOut, lpSecurityAttributes);
65 /* if (nMaxInstances > PIPE_UNLIMITED_INSTANCES) {
66 SetLastError (ERROR_INVALID_PARAMETER);
67 return INVALID_HANDLE_VALUE;
68 } */
70 SetLastError (ERROR_UNKNOWN);
71 return INVALID_HANDLE_VALUE;
74 /***********************************************************************
75 * CreateNamedPipeW (KERNEL32.169)
77 HANDLE WINAPI CreateNamedPipeW (LPCWSTR lpName, DWORD dwOpenMode,
78 DWORD dwPipeMode, DWORD nMaxInstances,
79 DWORD nOutBufferSize, DWORD nInBufferSize,
80 DWORD nDefaultTimeOut,
81 LPSECURITY_ATTRIBUTES lpSecurityAttributes)
83 FIXME("(Name=%s, OpenMode=%#08lx, dwPipeMode=%#08lx, MaxInst=%ld, OutBSize=%ld, InBuffSize=%ld, DefTimeOut=%ld, SecAttr=%p): stub\n",
84 debugstr_w(lpName), dwOpenMode, dwPipeMode, nMaxInstances,
85 nOutBufferSize, nInBufferSize, nDefaultTimeOut, lpSecurityAttributes);
87 SetLastError (ERROR_UNKNOWN);
88 return INVALID_HANDLE_VALUE;
91 /***********************************************************************
92 * GetSystemPowerStatus (KERNEL32.621)
94 BOOL WINAPI GetSystemPowerStatus(LPSYSTEM_POWER_STATUS sps_ptr)
96 return FALSE; /* no power management support */
100 /***********************************************************************
101 * SetSystemPowerState (KERNEL32.630)
103 BOOL WINAPI SetSystemPowerState(BOOL suspend_or_hibernate,
104 BOOL force_flag)
106 /* suspend_or_hibernate flag: w95 does not support
107 this feature anyway */
109 for ( ;0; )
111 if ( force_flag )
114 else
118 return TRUE;
122 /******************************************************************************
123 * CreateMailslot32A [KERNEL32.164]
125 HANDLE WINAPI CreateMailslotA( LPCSTR lpName, DWORD nMaxMessageSize,
126 DWORD lReadTimeout, LPSECURITY_ATTRIBUTES sa)
128 FIXME("(%s,%ld,%ld,%p): stub\n", debugstr_a(lpName),
129 nMaxMessageSize, lReadTimeout, sa);
130 return 1;
134 /******************************************************************************
135 * CreateMailslot32W [KERNEL32.165] Creates a mailslot with specified name
137 * PARAMS
138 * lpName [I] Pointer to string for mailslot name
139 * nMaxMessageSize [I] Maximum message size
140 * lReadTimeout [I] Milliseconds before read time-out
141 * sa [I] Pointer to security structure
143 * RETURNS
144 * Success: Handle to mailslot
145 * Failure: INVALID_HANDLE_VALUE
147 HANDLE WINAPI CreateMailslotW( LPCWSTR lpName, DWORD nMaxMessageSize,
148 DWORD lReadTimeout, LPSECURITY_ATTRIBUTES sa )
150 FIXME("(%s,%ld,%ld,%p): stub\n", debugstr_w(lpName),
151 nMaxMessageSize, lReadTimeout, sa);
152 return 1;
156 /******************************************************************************
157 * GetMailslotInfo [KERNEL32.347] Retrieves info about specified mailslot
159 * PARAMS
160 * hMailslot [I] Mailslot handle
161 * lpMaxMessageSize [O] Address of maximum message size
162 * lpNextSize [O] Address of size of next message
163 * lpMessageCount [O] Address of number of messages
164 * lpReadTimeout [O] Address of read time-out
166 * RETURNS
167 * Success: TRUE
168 * Failure: FALSE
170 BOOL WINAPI GetMailslotInfo( HANDLE hMailslot, LPDWORD lpMaxMessageSize,
171 LPDWORD lpNextSize, LPDWORD lpMessageCount,
172 LPDWORD lpReadTimeout )
174 FIXME("(%04x): stub\n",hMailslot);
175 if (lpMaxMessageSize) *lpMaxMessageSize = (DWORD)NULL;
176 if (lpNextSize) *lpNextSize = (DWORD)NULL;
177 if (lpMessageCount) *lpMessageCount = (DWORD)NULL;
178 if (lpReadTimeout) *lpReadTimeout = (DWORD)NULL;
179 return TRUE;
183 /******************************************************************************
184 * GetCompressedFileSize32A [KERNEL32.291]
186 * NOTES
187 * This should call the W function below
189 DWORD WINAPI GetCompressedFileSizeA(
190 LPCSTR lpFileName,
191 LPDWORD lpFileSizeHigh)
193 FIXME("(...): stub\n");
194 return 0xffffffff;
198 /******************************************************************************
199 * GetCompressedFileSize32W [KERNEL32.292]
201 * RETURNS
202 * Success: Low-order doubleword of number of bytes
203 * Failure: 0xffffffff
205 DWORD WINAPI GetCompressedFileSizeW(
206 LPCWSTR lpFileName, /* [in] Pointer to name of file */
207 LPDWORD lpFileSizeHigh) /* [out] Receives high-order doubleword of size */
209 FIXME("(%s,%p): stub\n",debugstr_w(lpFileName),lpFileSizeHigh);
210 return 0xffffffff;
214 /******************************************************************************
215 * GetProcessWindowStation [USER32.280] Returns handle of window station
217 * NOTES
218 * Docs say the return value is HWINSTA
220 * RETURNS
221 * Success: Handle to window station associated with calling process
222 * Failure: NULL
224 DWORD WINAPI GetProcessWindowStation(void)
226 FIXME("(void): stub\n");
227 return 1;
231 /******************************************************************************
232 * GetThreadDesktop [USER32.295] Returns handle to desktop
234 * NOTES
235 * Docs say the return value is HDESK
237 * PARAMS
238 * dwThreadId [I] Thread identifier
240 * RETURNS
241 * Success: Handle to desktop associated with specified thread
242 * Failure: NULL
244 DWORD WINAPI GetThreadDesktop( DWORD dwThreadId )
246 FIXME("(%lx): stub\n",dwThreadId);
247 return 1;
251 /******************************************************************************
252 * SetDebugErrorLevel [USER32.475]
253 * Sets the minimum error level for generating debugging events
255 * PARAMS
256 * dwLevel [I] Debugging error level
258 VOID WINAPI SetDebugErrorLevel( DWORD dwLevel )
260 FIXME("(%ld): stub\n", dwLevel);
264 /******************************************************************************
265 * SetComputerName32A [KERNEL32.621]
267 BOOL WINAPI SetComputerNameA( LPCSTR lpComputerName )
269 LPWSTR lpComputerNameW = HEAP_strdupAtoW(GetProcessHeap(),0,lpComputerName);
270 BOOL ret = SetComputerNameW(lpComputerNameW);
271 HeapFree(GetProcessHeap(),0,lpComputerNameW);
272 return ret;
276 /******************************************************************************
277 * SetComputerName32W [KERNEL32.622]
279 * PARAMS
280 * lpComputerName [I] Address of new computer name
282 * RETURNS STD
284 BOOL WINAPI SetComputerNameW( LPCWSTR lpComputerName )
286 FIXME("(%s): stub\n", debugstr_w(lpComputerName));
287 return TRUE;
291 BOOL WINAPI EnumPortsA(LPSTR name,DWORD level,LPBYTE ports,DWORD bufsize,LPDWORD bufneeded,LPDWORD bufreturned) {
292 FIXME("(%s,%ld,%p,%ld,%p,%p), stub!\n",name,level,ports,bufsize,bufneeded,bufreturned);
293 return FALSE;
296 /******************************************************************************
297 * IsDebuggerPresent [KERNEL32.827]
300 BOOL WINAPI IsDebuggerPresent() {
301 FIXME(" ... no debuggers yet, returning FALSE.\n");
302 return FALSE;
305 /******************************************************************************
306 * OpenDesktop32A [USER32.408]
308 * NOTES
309 * Return type should be HDESK
311 * Not supported on Win9x - returns NULL and calls SetLastError.
313 HANDLE WINAPI OpenDesktopA( LPCSTR lpszDesktop, DWORD dwFlags,
314 BOOL fInherit, DWORD dwDesiredAccess )
316 FIXME("(%s,%lx,%i,%lx): stub\n",debugstr_a(lpszDesktop),dwFlags,
317 fInherit,dwDesiredAccess);
319 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
320 return 0;
324 BOOL WINAPI SetUserObjectInformationA( HANDLE hObj, int nIndex,
325 LPVOID pvInfo, DWORD nLength )
327 FIXME("(%x,%d,%p,%lx): stub\n",hObj,nIndex,pvInfo,nLength);
328 return TRUE;
332 BOOL WINAPI SetThreadDesktop( HANDLE hDesktop )
334 FIXME("(%x): stub\n",hDesktop);
335 return TRUE;
338 HANDLE WINAPI CreateIoCompletionPort(HANDLE hFileHandle,
339 HANDLE hExistingCompletionPort, DWORD dwCompletionKey,
340 DWORD dwNumberOfConcurrentThreads)
342 FIXME("(%04x, %04x, %08lx, %08lx): stub.\n", hFileHandle, hExistingCompletionPort, dwCompletionKey, dwNumberOfConcurrentThreads);
343 return (HANDLE)NULL;
347 /******************************************************************************
348 * GetProcessDefaultLayout [USER32.802]
350 * Gets the default layout for parentless windows.
351 * Right now, just returns 0 (left-to-right).
353 * RETURNS
354 * Success: Nonzero
355 * Failure: Zero
357 * BUGS
358 * No RTL
360 BOOL WINAPI GetProcessDefaultLayout( DWORD *pdwDefaultLayout )
362 if ( !pdwDefaultLayout ) {
363 SetLastError( ERROR_INVALID_PARAMETER );
364 return FALSE;
366 FIXME( "( %p ): No BiDi\n", pdwDefaultLayout );
367 *pdwDefaultLayout = 0;
368 return TRUE;
372 /******************************************************************************
373 * SetProcessDefaultLayout [USER32.803]
375 * Sets the default layout for parentless windows.
376 * Right now, only accepts 0 (left-to-right).
378 * RETURNS
379 * Success: Nonzero
380 * Failure: Zero
382 * BUGS
383 * No RTL
385 BOOL WINAPI SetProcessDefaultLayout( DWORD dwDefaultLayout )
387 if ( dwDefaultLayout == 0 )
388 return TRUE;
389 FIXME( "( %08lx ): No BiDi\n", dwDefaultLayout );
390 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
391 return FALSE;