source: trunk/src/NTDLL/ntdll.cpp@ 9684

Last change on this file since 9684 was 9684, checked in by sandervl, 23 years ago

PF: Changes for building dll with GCC

File size: 3.7 KB
Line 
1/* $Id: ntdll.cpp,v 1.7 2003-01-16 15:22:37 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#ifndef __EMX__
37#include <builtin.h>
38#endif
39#include <stdlib.h>
40#include <string.h>
41#include <ctype.h>
42#include <misc.h>
43#include "unicode.h"
44
45#include "ntdll.h"
46#include <ntdllsec.h>
47
48/*****************************************************************************
49 * Types & Defines *
50 *****************************************************************************/
51
52#define NTSTATUS DWORD
53
54//SvL: per process heap for NTDLL
55HANDLE NTDLL_hHeap = 0;
56
57PROCESSTHREAD_SECURITYINFO ProcSecInfo = {0};
58
59/*****************************************************************************
60 * Name : DbgPrint
61 * Purpose : print a debug line to somewhere?
62 * Parameters:
63 * Variables :
64 * Result :
65 * Remark : NTDLL.21
66 * Status : UNTESTED STUB
67 *
68 * Author : Patrick Haller [Tue, 1999/06/01 09:00]
69 *****************************************************************************/
70void __cdecl DbgPrint(LPCSTR lpcstrFormat,LPVOID args)
71{
72 UCHAR szBuffer[600]; // as in original NTDLL.DLL
73 int rc;
74
75 rc = wvsnprintfA((LPSTR)szBuffer,
76 sizeof(szBuffer),
77 lpcstrFormat,
78 (va_list)args);
79
80 dprintf(("NTDLL: DbgPrint[%s]\n",
81 szBuffer));
82
83 //@@@PH raise debug exception if running in debugger
84}
85
86
87BOOL WINAPI NTDLL_LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
88{
89 dprintf(("NTDLL_LibMain: 0x%x 0x%lx %p\n", hinstDLL, fdwReason, lpvReserved));
90
91 switch (fdwReason) {
92 case DLL_PROCESS_ATTACH:
93 {
94 SID_IDENTIFIER_AUTHORITY sidIdAuth = {0};
95
96 NTDLL_hHeap = HeapCreate(0, 0x10000, 0);
97
98 ProcSecInfo.dwType = SECTYPE_PROCESS | SECTYPE_INITIALIZED;
99 RtlAllocateAndInitializeSid(&sidIdAuth, 1, 0, 0, 0, 0, 0, 0, 0, 0, &ProcSecInfo.SidUser.User.Sid);
100 ProcSecInfo.SidUser.User.Attributes = 0; //?????????
101
102 ProcSecInfo.pTokenGroups = (TOKEN_GROUPS*)Heap_Alloc(sizeof(TOKEN_GROUPS));
103 ProcSecInfo.pTokenGroups->GroupCount = 1;
104 RtlAllocateAndInitializeSid(&sidIdAuth, 1, 0, 0, 0, 0, 0, 0, 0, 0, &ProcSecInfo.PrimaryGroup.PrimaryGroup);
105 ProcSecInfo.pTokenGroups->Groups[0].Sid = ProcSecInfo.PrimaryGroup.PrimaryGroup;
106 ProcSecInfo.pTokenGroups->Groups[0].Attributes = 0; //????
107
108// pPrivilegeSet = NULL;
109// pTokenPrivileges= NULL;
110// TokenOwner = {0};
111// DefaultDACL = {0};
112// TokenSource = {0};
113 ProcSecInfo.TokenType = TokenPrimary;
114 break;
115 }
116 case DLL_PROCESS_DETACH:
117 HeapDestroy(NTDLL_hHeap);
118 NTDLL_hHeap = 0;
119 break;
120 case DLL_THREAD_ATTACH:
121 break;
122 case DLL_THREAD_DETACH:
123 break;
124 default:
125 break;
126 }
127 return TRUE;
128}
129
Note: See TracBrowser for help on using the repository browser.