PostgreSQL Source Code  git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
win32ntdll.c File Reference
#include "c.h"
#include "port/win32ntdll.h"
Include dependency graph for win32ntdll.c:

Go to the source code of this file.

Data Structures

struct  NtDllRoutine
 

Typedefs

typedef struct NtDllRoutine NtDllRoutine
 

Functions

int initialize_ntdll (void)
 

Variables

RtlGetLastNtStatus_t pg_RtlGetLastNtStatus
 
RtlNtStatusToDosError_t pg_RtlNtStatusToDosError
 
NtFlushBuffersFileEx_t pg_NtFlushBuffersFileEx
 
static const NtDllRoutine routines []
 
static bool initialized
 

Typedef Documentation

◆ NtDllRoutine

typedef struct NtDllRoutine NtDllRoutine

Function Documentation

◆ initialize_ntdll()

int initialize_ntdll ( void  )

Definition at line 39 of file win32ntdll.c.

40 {
41  HMODULE module;
42 
43  if (initialized)
44  return 0;
45 
46  if (!(module = LoadLibraryEx("ntdll.dll", NULL, 0)))
47  {
48  _dosmaperr(GetLastError());
49  return -1;
50  }
51 
52  for (int i = 0; i < lengthof(routines); ++i)
53  {
54  pg_funcptr_t address;
55 
56  address = (pg_funcptr_t) GetProcAddress(module, routines[i].name);
57  if (!address)
58  {
59  _dosmaperr(GetLastError());
60  FreeLibrary(module);
61 
62  return -1;
63  }
64 
65  *(pg_funcptr_t *) routines[i].address = address;
66  }
67 
68  initialized = true;
69 
70  return 0;
71 }
#define lengthof(array)
Definition: c.h:767
void(* pg_funcptr_t)(void)
Definition: c.h:403
int i
Definition: isn.c:72
const char * name
void _dosmaperr(unsigned long)
Definition: win32error.c:177
static const NtDllRoutine routines[]
Definition: win32ntdll.c:30
static bool initialized
Definition: win32ntdll.c:36

References _dosmaperr(), i, initialized, lengthof, name, and routines.

Referenced by fdatasync().

Variable Documentation

◆ initialized

bool initialized
static

Definition at line 36 of file win32ntdll.c.

Referenced by initialize_ntdll().

◆ pg_NtFlushBuffersFileEx

NtFlushBuffersFileEx_t pg_NtFlushBuffersFileEx

Definition at line 22 of file win32ntdll.c.

Referenced by fdatasync().

◆ pg_RtlGetLastNtStatus

RtlGetLastNtStatus_t pg_RtlGetLastNtStatus

Definition at line 20 of file win32ntdll.c.

Referenced by _pglstat64(), and _pgstat64().

◆ pg_RtlNtStatusToDosError

RtlNtStatusToDosError_t pg_RtlNtStatusToDosError

Definition at line 21 of file win32ntdll.c.

Referenced by fdatasync().

◆ routines

const NtDllRoutine routines[]
static
Initial value:
= {
{"RtlGetLastNtStatus", (pg_funcptr_t *) &pg_RtlGetLastNtStatus},
{"RtlNtStatusToDosError", (pg_funcptr_t *) &pg_RtlNtStatusToDosError},
{"NtFlushBuffersFileEx", (pg_funcptr_t *) &pg_NtFlushBuffersFileEx}
}
NtFlushBuffersFileEx_t pg_NtFlushBuffersFileEx
Definition: win32ntdll.c:22
RtlGetLastNtStatus_t pg_RtlGetLastNtStatus
Definition: win32ntdll.c:20
RtlNtStatusToDosError_t pg_RtlNtStatusToDosError
Definition: win32ntdll.c:21

Definition at line 30 of file win32ntdll.c.

Referenced by initialize_ntdll().