| 1 | /* $Id: ntdll.cpp,v 1.1 1999-06-07 22:17:40 sandervl Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | *
|
|---|
| 5 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 6 | * Win32 NT Runtime / NTDLL for OS/2
|
|---|
| 7 | *
|
|---|
| 8 | * Copyright 1998, 1999 Patrick Haller (phaller@gmx.net)
|
|---|
| 9 | *
|
|---|
| 10 | * @(#) ntdll.cpp 1.0.1 1999/05/08 SvL: Changes for compilation with Wine headers
|
|---|
| 11 | * 1.0.0 1998/05/20 PH Start from WINE/NTDLL.C
|
|---|
| 12 | *
|
|---|
| 13 | * NT basis DLL
|
|---|
| 14 | *
|
|---|
| 15 | * Copyright 1996 Marcus Meissner
|
|---|
| 16 | * Copyright 1998 Patrick Haller (adapted for win32os2)
|
|---|
| 17 | */
|
|---|
| 18 |
|
|---|
| 19 | /* Changes to the original NTDLL.C from the WINE project
|
|---|
| 20 |
|
|---|
| 21 | - includes replaced by the win32os2 standard includes
|
|---|
| 22 | - replaced WINAPI by WIN32API
|
|---|
| 23 | - moved in some string functions
|
|---|
| 24 | - replaced HANDLE32 by HANDLE
|
|---|
| 25 | - lstrlen32A -> OS2lstrlenA
|
|---|
| 26 | - lstrlen32W -> OS2lstrlenW
|
|---|
| 27 | */
|
|---|
| 28 |
|
|---|
| 29 | /*****************************************************************************
|
|---|
| 30 | * Includes *
|
|---|
| 31 | *****************************************************************************/
|
|---|
| 32 |
|
|---|
| 33 | #include <os2win.h>
|
|---|
| 34 | #include <winnt.h>
|
|---|
| 35 | #include <ntdef.h>
|
|---|
| 36 | #include <builtin.h>
|
|---|
| 37 | #include <stdlib.h>
|
|---|
| 38 | #include <string.h>
|
|---|
| 39 | #include <ctype.h>
|
|---|
| 40 | #include "misc.h"
|
|---|
| 41 | #include "unicode.h"
|
|---|
| 42 |
|
|---|
| 43 | #include "ntdll.h"
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 | /*****************************************************************************
|
|---|
| 47 | * Types & Defines *
|
|---|
| 48 | *****************************************************************************/
|
|---|
| 49 |
|
|---|
| 50 | #define NTSTATUS DWORD
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 | /***********************************************************************
|
|---|
| 54 | * lstrcpynAtoW (Not a Windows API)
|
|---|
| 55 | * Note: this function differs from the UNIX strncpy, it _always_ writes
|
|---|
| 56 | * a terminating \0
|
|---|
| 57 | */
|
|---|
| 58 | LPWSTR WIN32API lstrcpynAtoW(LPWSTR dst,
|
|---|
| 59 | LPCSTR src,
|
|---|
| 60 | INT n)
|
|---|
| 61 | {
|
|---|
| 62 | LPWSTR p = dst;
|
|---|
| 63 | while ((n-- > 1) && *src) *p++ = (WCHAR)(unsigned char)*src++;
|
|---|
| 64 | if (n >= 0) *p = 0;
|
|---|
| 65 | return dst;
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 | /***********************************************************************
|
|---|
| 70 | * lstrcpynWtoA (Not a Windows API)
|
|---|
| 71 | * Note: this function differs from the UNIX strncpy, it _always_ writes
|
|---|
| 72 | * a terminating \0
|
|---|
| 73 | */
|
|---|
| 74 | LPSTR WIN32API lstrcpynWtoA(LPSTR dst,
|
|---|
| 75 | LPCWSTR src,
|
|---|
| 76 | INT n)
|
|---|
| 77 | {
|
|---|
| 78 | LPSTR p = dst;
|
|---|
| 79 | while ((n-- > 1) && *src) *p++ = (CHAR)*src++;
|
|---|
| 80 | if (n >= 0) *p = 0;
|
|---|
| 81 | return dst;
|
|---|
| 82 | }
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 | /***********************************************************************
|
|---|
| 86 | * lstrncmp32W (Not a Windows API)
|
|---|
| 87 | */
|
|---|
| 88 | INT WIN32API lstrncmpW( LPCWSTR str1, LPCWSTR str2, INT n )
|
|---|
| 89 | {
|
|---|
| 90 | if (!n)
|
|---|
| 91 | return 0;
|
|---|
| 92 |
|
|---|
| 93 | while ((--n > 0) && *str1 && (*str1 == *str2))
|
|---|
| 94 | {
|
|---|
| 95 | str1++;
|
|---|
| 96 | str2++;
|
|---|
| 97 | }
|
|---|
| 98 |
|
|---|
| 99 | return (INT)(*str1 - *str2);
|
|---|
| 100 | }
|
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 | /***********************************************************************
|
|---|
| 105 | * HEAP_strdupA
|
|---|
| 106 | */
|
|---|
| 107 | LPSTR HEAP_strdupA(HANDLE heap,
|
|---|
| 108 | DWORD flags,
|
|---|
| 109 | LPCSTR str)
|
|---|
| 110 | {
|
|---|
| 111 | LPSTR p = (LPSTR)HeapAlloc(heap,
|
|---|
| 112 | flags,
|
|---|
| 113 | lstrlenA(str) + 1 );
|
|---|
| 114 |
|
|---|
| 115 | lstrcpyA(p, str);
|
|---|
| 116 | return p;
|
|---|
| 117 | }
|
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 | /***********************************************************************
|
|---|
| 121 | * HEAP_strdupW
|
|---|
| 122 | */
|
|---|
| 123 | LPWSTR HEAP_strdupW(HANDLE heap,
|
|---|
| 124 | DWORD flags,
|
|---|
| 125 | LPCWSTR str)
|
|---|
| 126 | {
|
|---|
| 127 | INT len = lstrlenW(str) + 1;
|
|---|
| 128 | LPWSTR p = (LPWSTR)HeapAlloc(heap,
|
|---|
| 129 | flags,
|
|---|
| 130 | len * sizeof(WCHAR) );
|
|---|
| 131 | lstrcpyW(p,
|
|---|
| 132 | str);
|
|---|
| 133 | return p;
|
|---|
| 134 | }
|
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 | /***********************************************************************
|
|---|
| 138 | * HEAP_strdupWtoA
|
|---|
| 139 | */
|
|---|
| 140 | LPSTR HEAP_strdupWtoA(HANDLE heap,
|
|---|
| 141 | DWORD flags,
|
|---|
| 142 | LPCWSTR str )
|
|---|
| 143 | {
|
|---|
| 144 | LPSTR ret;
|
|---|
| 145 |
|
|---|
| 146 | if (!str)
|
|---|
| 147 | return NULL;
|
|---|
| 148 |
|
|---|
| 149 | ret = (LPSTR)HeapAlloc(heap,
|
|---|
| 150 | flags,
|
|---|
| 151 | lstrlenW(str) + 1 );
|
|---|
| 152 | UnicodeToAscii((LPWSTR)str,
|
|---|
| 153 | ret);
|
|---|
| 154 | /* lstrcpyWtoA(ret,
|
|---|
| 155 | str);*/
|
|---|
| 156 | return ret;
|
|---|
| 157 | }
|
|---|
| 158 |
|
|---|
| 159 | /***********************************************************************
|
|---|
| 160 | * HEAP_strdupAtoW
|
|---|
| 161 | */
|
|---|
| 162 | LPWSTR HEAP_strdupAtoW(HANDLE heap,
|
|---|
| 163 | DWORD flags,
|
|---|
| 164 | LPCSTR str)
|
|---|
| 165 | {
|
|---|
| 166 | LPWSTR ret;
|
|---|
| 167 |
|
|---|
| 168 | if (!str)
|
|---|
| 169 | return NULL;
|
|---|
| 170 |
|
|---|
| 171 | ret = (LPWSTR)HeapAlloc(heap,
|
|---|
| 172 | flags,
|
|---|
| 173 | (lstrlenA(str)+1) * sizeof(WCHAR) );
|
|---|
| 174 | AsciiToUnicode((char *)str,
|
|---|
| 175 | ret);
|
|---|
| 176 | /* lstrcpyAtoW(ret,
|
|---|
| 177 | str );*/
|
|---|
| 178 |
|
|---|
| 179 | return ret;
|
|---|
| 180 | }
|
|---|
| 181 |
|
|---|