| 1 | /* $Id: ntdll.c,v 1.8 2003-04-08 12:47:06 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 <windows.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 | #include <versionos2.h>
|
|---|
| 48 | /*****************************************************************************
|
|---|
| 49 | * Types & Defines *
|
|---|
| 50 | *****************************************************************************/
|
|---|
| 51 |
|
|---|
| 52 | #define NTSTATUS DWORD
|
|---|
| 53 |
|
|---|
| 54 | PROCESSTHREAD_SECURITYINFO ProcSecInfo = {0};
|
|---|
| 55 |
|
|---|
| 56 | /*****************************************************************************
|
|---|
| 57 | * Name : DbgPrint
|
|---|
| 58 | * Purpose : print a debug line to somewhere?
|
|---|
| 59 | * Parameters:
|
|---|
| 60 | * Variables :
|
|---|
| 61 | * Result :
|
|---|
| 62 | * Remark : NTDLL.21
|
|---|
| 63 | * Status : UNTESTED STUB
|
|---|
| 64 | *
|
|---|
| 65 | * Author : Patrick Haller [Tue, 1999/06/01 09:00]
|
|---|
| 66 | *****************************************************************************/
|
|---|
| 67 | void __cdecl DbgPrint(LPCSTR lpcstrFormat,LPVOID args)
|
|---|
| 68 | {
|
|---|
| 69 | UCHAR szBuffer[600]; // as in original NTDLL.DLL
|
|---|
| 70 | int rc;
|
|---|
| 71 |
|
|---|
| 72 | rc = wvsnprintfA((LPSTR)szBuffer,
|
|---|
| 73 | sizeof(szBuffer),
|
|---|
| 74 | lpcstrFormat,
|
|---|
| 75 | (va_list)args);
|
|---|
| 76 |
|
|---|
| 77 | dprintf(("NTDLL: DbgPrint[%s]\n",
|
|---|
| 78 | szBuffer));
|
|---|
| 79 |
|
|---|
| 80 | //@@@PH raise debug exception if running in debugger
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 | //******************************************************************************
|
|---|
| 84 | BOOL WIN32API NTDLL_LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|---|
| 85 | {
|
|---|
| 86 | dprintf(("NTDLL_LibMain: 0x%x 0x%lx %p\n", hinstDLL, fdwReason, lpvReserved));
|
|---|
| 87 |
|
|---|
| 88 | switch (fdwReason) {
|
|---|
| 89 | case DLL_PROCESS_ATTACH:
|
|---|
| 90 | {
|
|---|
| 91 | SID_IDENTIFIER_AUTHORITY sidIdAuth = {0};
|
|---|
| 92 |
|
|---|
| 93 | ProcSecInfo.dwType = SECTYPE_PROCESS | SECTYPE_INITIALIZED;
|
|---|
| 94 | RtlAllocateAndInitializeSid(&sidIdAuth, 1, 0, 0, 0, 0, 0, 0, 0, 0, &ProcSecInfo.SidUser.User.Sid);
|
|---|
| 95 | ProcSecInfo.SidUser.User.Attributes = 0; //?????????
|
|---|
| 96 |
|
|---|
| 97 | ProcSecInfo.pTokenGroups = (TOKEN_GROUPS*)Heap_Alloc(sizeof(TOKEN_GROUPS));
|
|---|
| 98 | ProcSecInfo.pTokenGroups->GroupCount = 1;
|
|---|
| 99 | RtlAllocateAndInitializeSid(&sidIdAuth, 1, 0, 0, 0, 0, 0, 0, 0, 0, &ProcSecInfo.PrimaryGroup.PrimaryGroup);
|
|---|
| 100 | ProcSecInfo.pTokenGroups->Groups[0].Sid = ProcSecInfo.PrimaryGroup.PrimaryGroup;
|
|---|
| 101 | ProcSecInfo.pTokenGroups->Groups[0].Attributes = 0; //????
|
|---|
| 102 |
|
|---|
| 103 | // pPrivilegeSet = NULL;
|
|---|
| 104 | // pTokenPrivileges= NULL;
|
|---|
| 105 | // TokenOwner = {0};
|
|---|
| 106 | // DefaultDACL = {0};
|
|---|
| 107 | // TokenSource = {0};
|
|---|
| 108 | ProcSecInfo.TokenType = TokenPrimary;
|
|---|
| 109 | break;
|
|---|
| 110 | }
|
|---|
| 111 | case DLL_PROCESS_DETACH:
|
|---|
| 112 | break;
|
|---|
| 113 | case DLL_THREAD_ATTACH:
|
|---|
| 114 | break;
|
|---|
| 115 | case DLL_THREAD_DETACH:
|
|---|
| 116 | break;
|
|---|
| 117 | default:
|
|---|
| 118 | break;
|
|---|
| 119 | }
|
|---|
| 120 | return TRUE;
|
|---|
| 121 | }
|
|---|