uLib  User mode C/C++ extended API library for Win32 programmers.
KernelUtil.cpp File Reference
#include <uLib/Common.h>
#include <uLib/UtilFunc.h>
#include <uLib/Debug.h>
#include <uLib/StrFunc.h>
#include <uLib/NtFunc.h>
#include <uLib/LargeInt.h>

Go to the source code of this file.

Namespaces

 uLib
 

Macros

#define FHDR_SIZE   sizeof(Hdr->FileHeader)
 
#define OPTHDR_SIZE   sizeof(Hdr->OptionalHeader)
 
#define IMAGE_FILE_MACHINE_ALPHA   0x0184
 
#define IMAGE_FILE_MACHINE_ALPHA64   0x0284
 
#define IMAGE_FILE_MACHINE_R3000   0x0162
 
#define IMAGE_FILE_MACHINE_R4000   0x0166
 
#define IMAGE_FILE_MACHINE_R10000   0x0168
 
#define IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION   16
 

Functions

UINT GlobalPurgeAtom (CSTR Name)
 
CSTR GlobalAtomName (ATOM Atom)
 
CSTR LocalAtomName (ATOM Atom)
 
HANDLE GetCurrentThreadHandle ()
 
HANDLE GetCurrentProcessHandle ()
 
HANDLE CheckHandle (HANDLE Hnd)
 
HANDLE CloseHandleEx (HANDLE Hnd)
 
bool WaitFor (HANDLE hObj, DWORD msWait)
 
ASTR GlobalAllocStrA (UINT Count)
 
WSTR GlobalAllocStrW (UINT Count)
 
BEGIN_STRSAFE_OVERRIDE ASTR GlobalDupStrA (ACSTR Str, bool isMulti)
 
WSTR GlobalDupStrW (WCSTR Str, bool isMulti)
 
END_STRSAFE_OVERRIDE HANDLE GlobalUnlockedHandle (PVOID Ptr, PUINT pCount)
 
bool IsBadReadWritePtr (const PVOID address, UINT_PTR size)
 
HANDLE Launch (CSTR exePath, CSTR cmdLn, CSTR startDir, int iShow, DWORD Flags)
 
HANDLE CreateCapturedProcess (IN CSTR cmdLn, IN LPSTARTUPINFO si, IN DWORD Flags, OPTOUT PHANDLE pRdHnd, OPTOUT PHANDLE pWrHnd, OPTOUT PHANDLE pErrHnd, OPTOUT PHANDLE phThread)
 
HANDLE CreateCapturedProcessEx (OPTIN CSTR ExePath, OPTIN CSTR CmdLn, OPTIN CSTR EnvStr, OPTIN CSTR WorkDir, IN LPSTARTUPINFO pSI, IN DWORD Flags, OPTOUT PHANDLE pRdHnd, OPTOUT PHANDLE pWrHnd, OPTOUT PHANDLE pErrHnd, OPTOUT PHANDLE phThread)
 
HANDLE CloseCapturedProcess (IN HANDLE hProc, IN LPSTARTUPINFO pSi, IN PHANDLE pRdHnd, IN PHANDLE pWrHnd, IN PHANDLE pErrHnd)
 
HANDLE TerminateCapturedProcess (IN HANDLE hProc, IN LPSTARTUPINFO pSi, IN PHANDLE pRdHnd, IN PHANDLE pWrHnd, IN PHANDLE pErrHnd, IN UINT retCode)
 
HMODULE GetOrLoadModule (CSTR modName)
 
HMODULE LoadProcLibrary (HANDLE hProc, LPCSTR DllPathName, DWORD msWait)
 
BOOL UnloadProcLibrary (HANDLE hProc, HMODULE hLib, DWORD msWait)
 
SHORT GetProcDLLRefCount (HANDLE hProcess, WCSTR DllName)
 
HMODULE GetProcDLLHandle (HANDLE hProcess, WCSTR DllName)
 
FILETIME uLib::Now (eTimeType Domain)
 
FILETIME uLib::AddTime (FILETIME Time, SHORT Hr, SHORT Min, SHORT Sec, SHORT mSec)
 
FILETIME uLib::AddFiletime (FILETIME Time, const FILETIME Add)
 
FILETIME uLib::MakeDateTime (WORD Year, WORD Month, WORD Day, WORD Hr, WORD Min, WORD Sec)
 
bool uLib::operator > (FILETIME const &A, FILETIME const &B)
 
bool uLib::operator< (FILETIME const &A, FILETIME const &B)
 
bool uLib::operator== (FILETIME const &A, FILETIME const &B)
 
bool uLib::operator >= (FILETIME const &A, FILETIME const &B)
 
bool uLib::operator<= (FILETIME const &A, FILETIME const &B)
 
bool uLib::operator != (FILETIME const &A, FILETIME const &B)
 
SYSTEMTIME * SystemTimeToLocalTime (SYSTEMTIME *Time)
 
SYSTEMTIME * LocalTimeToSystemTime (SYSTEMTIME *Time)
 
FILETIME FileTimeToLocalTime (FILETIME utc)
 
bool GetEnvironmentSize (WSTR pwEnv, PUINT pSize, PUINT pUsed)
 
WSTR CloneEnvironment (OPTOUT PUINT pLength, OPTOUT PUINT pUsed)
 
WSTR FreeEnvironment (WSTR Env)
 
bool SetEnvironmentVar (OPTIO WSTR *pwEnv, IN CSTR Name, IN CSTR Value)
 
bool GetEnvironmentVar (OPTIN WSTR pwEnv, IN CSTR Name, OUT TSTR Value, INOUT PUINT ccValBuf)
 
UINT ModifyEnvironmentVar (WSTR *pwEnv, BYTE Option, CSTR Name, CSTR Addendum, TCHAR Sep)
 
UINT DeduplicatePathStr (TSTR Path)
 
bool ReadNTHeaders (CSTR ExeName, IMAGE_NT_HEADERS *Hdr, bool getOptHdr)
 
WORD GetTargetMachine (CSTR ExeName)
 
bool Is64BitExecutable (CSTR ExeName)
 
WORD GetInstanceTargetMachine (HINSTANCE hInst)
 
bool Is64BitInstance (HINSTANCE hInst)
 
bool Is32BitInstance (HINSTANCE hInst)
 
CSTR GetMachineStr (WORD Machine)
 
CSTR GetSubSystemStr (WORD SubSys)
 

Variables

const FILETIME uLib::NullFileTime = {0,0}
 

Macro Definition Documentation

◆ FHDR_SIZE

#define FHDR_SIZE   sizeof(Hdr->FileHeader)

◆ OPTHDR_SIZE

#define OPTHDR_SIZE   sizeof(Hdr->OptionalHeader)

◆ IMAGE_FILE_MACHINE_ALPHA

#define IMAGE_FILE_MACHINE_ALPHA   0x0184

Definition at line 1092 of file KernelUtil.cpp.

◆ IMAGE_FILE_MACHINE_ALPHA64

#define IMAGE_FILE_MACHINE_ALPHA64   0x0284

Definition at line 1093 of file KernelUtil.cpp.

◆ IMAGE_FILE_MACHINE_R3000

#define IMAGE_FILE_MACHINE_R3000   0x0162

Definition at line 1096 of file KernelUtil.cpp.

◆ IMAGE_FILE_MACHINE_R4000

#define IMAGE_FILE_MACHINE_R4000   0x0166

Definition at line 1097 of file KernelUtil.cpp.

◆ IMAGE_FILE_MACHINE_R10000

#define IMAGE_FILE_MACHINE_R10000   0x0168

Definition at line 1098 of file KernelUtil.cpp.

◆ IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION

#define IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION   16

Definition at line 1147 of file KernelUtil.cpp.

Function Documentation

◆ CreateCapturedProcess()

HANDLE CreateCapturedProcess ( IN CSTR  cmdLn,
IN LPSTARTUPINFO  si,
IN DWORD  Flags,
OPTOUT PHANDLE  pRdHnd,
OPTOUT PHANDLE  pWrHnd,
OPTOUT PHANDLE  pErrHnd,
OPTOUT PHANDLE  phThread 
)

Definition at line 218 of file KernelUtil.cpp.

◆ CreateCapturedProcessEx()

HANDLE CreateCapturedProcessEx ( OPTIN CSTR  ExePath,
OPTIN CSTR  CmdLn,
OPTIN CSTR  EnvStr,
OPTIN CSTR  WorkDir,
IN LPSTARTUPINFO  pSI,
IN DWORD  Flags,
OPTOUT PHANDLE  pRdHnd,
OPTOUT PHANDLE  pWrHnd,
OPTOUT PHANDLE  pErrHnd,
OPTOUT PHANDLE  phThread 
)

Definition at line 273 of file KernelUtil.cpp.

◆ CloseCapturedProcess()

HANDLE CloseCapturedProcess ( IN HANDLE  hProc,
IN LPSTARTUPINFO  pSi,
IN PHANDLE  pRdHnd,
IN PHANDLE  pWrHnd,
IN PHANDLE  pErrHnd 
)

Definition at line 337 of file KernelUtil.cpp.

◆ TerminateCapturedProcess()

HANDLE TerminateCapturedProcess ( IN HANDLE  hProc,
IN LPSTARTUPINFO  pSi,
IN PHANDLE  pRdHnd,
IN PHANDLE  pWrHnd,
IN PHANDLE  pErrHnd,
IN UINT  retCode 
)

Definition at line 357 of file KernelUtil.cpp.

◆ SystemTimeToLocalTime()

SYSTEMTIME* SystemTimeToLocalTime ( SYSTEMTIME *  Time)

Definition at line 660 of file KernelUtil.cpp.

◆ LocalTimeToSystemTime()

SYSTEMTIME* LocalTimeToSystemTime ( SYSTEMTIME *  Time)

Definition at line 676 of file KernelUtil.cpp.

◆ ModifyEnvironmentVar()

UINT ModifyEnvironmentVar ( WSTR pwEnv,
BYTE  Option,
CSTR  Name,
CSTR  Addendum,
TCHAR  Sep 
)

Definition at line 921 of file KernelUtil.cpp.

◆ DeduplicatePathStr()

UINT DeduplicatePathStr ( TSTR  Path)

Definition at line 976 of file KernelUtil.cpp.