PostgreSQL Source Code  git master
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
 

Macros

#define UMDF_USING_NTSTATUS
 

Typedefs

typedef struct NtDllRoutine NtDllRoutine
 

Functions

int initialize_ntdll (void)
 

Variables

RtlGetLastNtStatus_t pg_RtlGetLastNtStatus
 
static const NtDllRoutine routines []
 
static bool initialized
 

Macro Definition Documentation

◆ UMDF_USING_NTSTATUS

#define UMDF_USING_NTSTATUS

Definition at line 16 of file win32ntdll.c.

Typedef Documentation

◆ NtDllRoutine

typedef struct NtDllRoutine NtDllRoutine

Function Documentation

◆ initialize_ntdll()

int initialize_ntdll ( void  )

Definition at line 37 of file win32ntdll.c.

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

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

Variable Documentation

◆ initialized

bool initialized
static

Definition at line 34 of file win32ntdll.c.

Referenced by initialize_ntdll().

◆ pg_RtlGetLastNtStatus

RtlGetLastNtStatus_t pg_RtlGetLastNtStatus

Definition at line 22 of file win32ntdll.c.

◆ routines

const NtDllRoutine routines[]
static
Initial value:
= {
{"RtlGetLastNtStatus", (pg_funcptr_t *) &pg_RtlGetLastNtStatus}
}
RtlGetLastNtStatus_t pg_RtlGetLastNtStatus
Definition: win32ntdll.c:22

Definition at line 30 of file win32ntdll.c.

Referenced by initialize_ntdll().