PostgreSQL Source Code  git master
win32ntdll.h File Reference
#include <ntstatus.h>
#include <winternl.h>
Include dependency graph for win32ntdll.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef NTSTATUS(__stdcall * RtlGetLastNtStatus_t) (void)
 

Functions

int initialize_ntdll (void)
 

Variables

PGDLLIMPORT RtlGetLastNtStatus_t pg_RtlGetLastNtStatus
 

Typedef Documentation

◆ RtlGetLastNtStatus_t

typedef NTSTATUS(__stdcall * RtlGetLastNtStatus_t) (void)

Definition at line 26 of file win32ntdll.h.

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

◆ pg_RtlGetLastNtStatus

PGDLLIMPORT RtlGetLastNtStatus_t pg_RtlGetLastNtStatus
extern

Definition at line 22 of file win32ntdll.c.