15 #ifdef __cplusplus // FILETIME comparators... 27 while( 0 != (A = GlobalFindAtom( Name ))) {
28 GlobalDeleteAtom( A );
38 static TCHAR buf[ 80 ];
39 if (!GlobalGetAtomName( Atom, buf,
dimof(buf) )) buf[0] = 0;
45 static TCHAR buf[ 80 ];
46 if (!GetAtomName( Atom, buf,
dimof(buf) )) buf[0] = 0;
56 HANDLE hThread = GetCurrentThread(), hProc = GetCurrentProcess();
58 DuplicateHandle( hProc, hThread, hProc, &hThread, 0, FALSE, DUPLICATE_SAME_ACCESS );
64 HANDLE hProc = GetCurrentProcess();
66 DuplicateHandle( hProc, hProc, hProc, &hProc, 0, FALSE, DUPLICATE_SAME_ACCESS );
82 if (Hnd == INVALID_HANDLE_VALUE) Hnd = NULL;
85 #ifdef HAVE_STRUCTURED_EH 86 __try {
if (CloseHandle( Hnd )) Hnd = NULL; }
89 if (CloseHandle( Hnd )) Hnd = NULL;
97 DWORD rc = WaitForSingleObjectEx( hObj, msWait,
true );
98 bool ok = (rc == WAIT_OBJECT_0);
99 if (!ok) SetLastError( rc );
110 return (
ASTR) GlobalAllocPtr( GHND, Count );
124 UINT Len = isMulti ?
MultiSzLengthA( Str ) : UINT( 1+strlen( Str ));
126 if (pDup) memcpy( pDup, Str, Len );
147 UINT Len = isMulti ?
MultiSzLengthW( Str ) : UINT( 1+wcslen( Str ));
149 if (pDup) memcpy( pDup, Str, Len *
WCHAR_SIZE );
159 HANDLE hMem = GlobalHandle( Ptr );
166 locked = GlobalUnlock( hMem );
167 if (!locked && GetLastError() != 0) hMem = NULL;
170 if (pCount) *pCount = lockCount;
181 return (IsBadReadPtr( address, size ) || IsBadWritePtr( address, size ));
190 LPSECURITY_ATTRIBUTES sa = &
DefSec;
191 PROCESS_INFORMATION pi = { NULL,NULL, 0,0 };
194 NULL,NULL,NULL, 0,0,0,0,0,0,0,0,0,0,0, NULL,NULL,NULL
198 #if 0 // CreateProcess handles sending the process to the right desktop by default 199 si.lpDesktop = _T(
"winsta0\\default");
201 si.wShowWindow = iShow;
202 si.dwFlags = STARTF_USESHOWWINDOW;
204 if (!CreateProcess( exePath, (
TSTR)cmdLn, sa,sa, FALSE, Flags, pEnv, startDir, &si,&pi ))
209 if (pi.hThread) CloseHandle( pi.hThread );
228 PROCESS_INFORMATION ppi = { 0,0,0,0 };
230 SetLastError( ERROR_INVALID_PARAMETER );
233 if (pRdHnd) CreatePipe( pRdHnd, &si->hStdOutput, &
DefSec, 0 );
234 if (pWrHnd) CreatePipe( &si->hStdInput, pWrHnd, &
DefSec, 0 );
235 if (pErrHnd) CreatePipe( pErrHnd, &si->hStdError, &
DefSec, 0 );
238 if (pRdHnd != NULL) ok = (*pRdHnd != NULL);
239 if ((pWrHnd != NULL) && ok) ok = (*pWrHnd != NULL);
240 if ((pErrHnd != NULL) && ok) ok = (*pErrHnd != NULL);
243 si->dwFlags |= STARTF_USESTDHANDLES;
244 if (CreateProcess( NULL, (
TSTR)cmdLn, &
DefSec, &
DefSec, TRUE, Flags, 0,0, si, &ppi ))
246 if (phThread) *phThread = ppi.hThread;
264 if (phThread) *phThread = NULL;
278 IN LPSTARTUPINFO pSI,
286 PROCESS_INFORMATION pi = { 0,0,0,0 };
288 SetLastError( ERROR_INVALID_PARAMETER );
292 if (pRdHnd) CreatePipe( pRdHnd, &pSI->hStdOutput, &
DefSec, 0 );
293 if (pWrHnd) CreatePipe( &pSI->hStdInput, pWrHnd, &
DefSec, 0 );
294 if (pErrHnd) CreatePipe( pErrHnd, &pSI->hStdError, &
DefSec, 0 );
297 if (pRdHnd != NULL) ok = (*pRdHnd != NULL);
298 if ((pWrHnd != NULL) && ok) ok = (*pWrHnd != NULL);
299 if ((pErrHnd != NULL) && ok) ok = (*pErrHnd != NULL);
302 pSI->dwFlags |= STARTF_USESTDHANDLES;
304 if (CreateProcess( ExePath,
TSTR(CmdLn),
305 &
DefSec, &
DefSec,
true, Flags, PVOID(EnvStr), WorkDir, pSI, &pi
308 if (phThread) *phThread = pi.hThread;
312 else err = GetLastError();
327 if (phThread) *phThread = NULL;
328 if (err) SetLastError( err );
339 IN LPSTARTUPINFO pSi,
359 IN LPSTARTUPINFO pSi,
366 if (hProc && !TerminateProcess( hProc, retCode ))
378 HMODULE hMod = GetModuleHandle( modName );
379 if (!hMod) hMod = LoadLibrary( modName );
393 #pragma GCC diagnostic push 394 #pragma GCC diagnostic ignored "-Wcast-function-type" 399 DWORD err = NO_ERROR;
401 static HMODULE (WINAPI *_LoadLibrary)( LPCSTR pPathName ) = NULL;
409 HMODULE hKernel = GetModuleHandleA(
"KERNEL32.DLL" );
410 LITERAL( FARPROC, _LoadLibrary ) = GetProcAddress( hKernel,
"LoadLibraryA" );
415 PVOID pPath = VirtualAllocEx( hProc, NULL, MAX_PATH, MEM_COMMIT, PAGE_READWRITE );
418 err = GetLastError();
421 SIZE_T cbWr, len = 1+strlen( DllPathName );
425 TRACE(
DP_VERBOSE,
_F(
"WriteProcessMemory [%p,%p] '%s'\n"), hProc, pPath, DllPathName );
426 if (!WriteProcessMemory( hProc, pPath, (PVOID)DllPathName, len, &cbWr ))
427 err = GetLastError();
434 HANDLE hThr = CreateRemoteThread(
435 hProc, NULL,0, (LPTHREAD_START_ROUTINE)_LoadLibrary, pPath, 0,NULL
437 if (!hThr) err = GetLastError();
442 DWORD wr = WaitForSingleObject( hThr, msWait );
444 if (wr == WAIT_OBJECT_0)
446 if (!GetExitCodeThread( hThr, (LPDWORD)&retCode ))
448 err = GetLastError();
462 hMod = (HMODULE) retCode;
467 VirtualFreeEx( hProc, pPath, 0, MEM_RELEASE );
471 if (err) SetLastError( err );
475 #pragma GCC diagnostic pop 486 static BOOL (WINAPI *_FreeLibrary)( HMODULE hLib ) = NULL;
493 HMODULE hKernel = GetModuleHandleA(
"KERNEL32.DLL" );
494 LITERAL( FARPROC,_FreeLibrary ) = GetProcAddress( hKernel,
"FreeLibrary" );
501 HANDLE hThr = CreateRemoteThread(
502 hProc, NULL,0, (LPTHREAD_START_ROUTINE)_FreeLibrary, hLib, 0,NULL
507 if (WaitForSingleObject( hThr, msWait ) == WAIT_OBJECT_0)
508 GetExitCodeThread( hThr, (LPDWORD)&retCode );
518 #ifndef NO_NDK_FILES // These two require native data types. 524 IF_DEBUG( memset( &lm, 0,
sizeof(lm) ));
535 IF_DEBUG( memset( &lm, 0,
sizeof(lm) ));
542 #endif//ndef NO_NDK_FILES 552 FILETIME result = {0,0};
556 case LOCAL_TIME: GetLocalTime( &sysTime );
break;
557 case SYSTEM_TIME: GetSystemTime( &sysTime );
break;
558 default:
goto __done;
560 SystemTimeToFileTime( &sysTime, &result );
561 __done:
return result;
564 FILETIME
AddTime( FILETIME Time, SHORT Hr, SHORT Min, SHORT Sec, SHORT mSec )
570 static const int ms_Sec = 1000;
571 static const int ms_Min = 60*1000;
572 static const int ms_Hour = 60*60*1000;
573 static const int ms_Day = 24*60*60*1000;
575 FileTimeToSystemTime( &Time, &st );
576 ms = st.wMilliseconds + (st.wSecond * ms_Sec) + (st.wMinute * ms_Min) + (st.wHour * ms_Hour);
577 add = mSec + (Sec * ms_Sec) + (Min * ms_Min) + (Hr * ms_Hour);
580 st.wHour = ms / ms_Hour;
581 ms -= (st.wHour * ms_Hour);
583 st.wMinute = ms / ms_Min;
584 ms -= (st.wMinute * ms_Min);
586 st.wSecond = (ms / ms_Sec);
587 ms -= (st.wSecond * ms_Sec);
589 st.wMilliseconds = ms;
591 SystemTimeToFileTime( &st, &result );
599 FileTimeToSystemTime( &Add, &st );
603 return AddTime( Time, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds );
617 st.wDayOfWeek = st.wMilliseconds = 0;
619 SystemTimeToFileTime( &st, &result );
623 #ifdef __cplusplus // FILETIME comparators... 662 TIME_ZONE_INFORMATION tzi;
667 DWORD rc = GetTimeZoneInformation( &tzi );
668 _ASSERTE( rc != TIME_ZONE_ID_INVALID );
669 if( SystemTimeToTzSpecificLocalTime( &tzi, Time, &local ))
678 TIME_ZONE_INFORMATION tzi;
683 DWORD rc = GetTimeZoneInformation( &tzi );
684 _ASSERTE( rc != TIME_ZONE_ID_INVALID );
685 if( TzSpecificLocalTimeToSystemTime( &tzi, Time, &utc ))
696 if (!FileTimeToLocalFileTime( &utc, &local ))
703 static HMODULE GetNtDll()
705 static HMODULE ntDll;
706 if (!ntDll) ntDll = GetModuleHandle( _T(
"NTDLL") );
716 WSTR pzEnv, pEnv = pwEnv ? pwEnv : GetEnvironmentStringsW();
717 bool ok = (pEnv != NULL);
718 if (pSize) *pSize = 0;
719 if (pUsed) *pUsed = 0;
722 for( pzEnv = pEnv; *pzEnv; pzEnv = 1 + wcschr( pzEnv, 0 ));
723 UINT ccEnv = UINT( (pzEnv - pEnv) + 1 );
725 MEMORY_BASIC_INFORMATION mbi;
726 ok = (VirtualQuery( pEnv, &mbi,
sizeof(mbi) ) > 0);
729 if (pSize) *pSize = UINT( mbi.RegionSize /
WCHAR_SIZE );
730 if (pUsed) *pUsed = ccEnv;
732 if (!pwEnv) FreeEnvironmentStringsW( pEnv );
753 WSTR pwEnv = NULL, pzEnv;
756 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
767 for( pzEnv = pwEnv; *pzEnv; pzEnv = 1 + wcschr( pzEnv, 0 ));
768 UINT_PTR ccUsed = (pzEnv - pwEnv) + 1;
769 if (pUsed) *pUsed = (UINT) ccUsed;
771 MEMORY_BASIC_INFORMATION mbi;
772 IF_DEBUG( memset( &mbi, 0,
sizeof(mbi) ));
773 if (VirtualQuery( pwEnv, &mbi,
sizeof(mbi) ))
775 UINT ccEnv = UINT( mbi.RegionSize /
WCHAR_SIZE );
776 if (pLength) *pLength = ccEnv;
780 _F(
"AllocationBase=%#x, BaseAddress=%#x, RegionSize=%lu, State=0x%08X\n"),
781 mbi.AllocationBase, mbi.BaseAddress, mbi.RegionSize, mbi.State
784 static const UINT MAX_ENV = 32767 *
WCHAR_SIZE;
785 if (mbi.RegionSize > MAX_ENV)
787 _F(
"Non-compliant environment size: %lu B (%lu ch)! %lu B used\n"),
788 mbi.RegionSize, ccEnv, cbUsed
804 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
807 if ( !Env ) SetLastError( ERROR_INVALID_PARAMETER );
812 MEMORY_BASIC_INFORMATION mbi;
813 memset( &mbi, 0,
sizeof(mbi) );
814 if (VirtualQuery( Env, &mbi,
sizeof(mbi) ))
817 _F(
"After: AllocationBase=%#x, BaseAddress=%#x, RegionSize=%lu, State=%lu\n"),
818 mbi.AllocationBase, mbi.BaseAddress, mbi.RegionSize, mbi.State
831 #ifndef NO_WINTERNAL // UNICODE_STRING 844 PWSTR* Environment, PUNICODE_STRING Name, PUNICODE_STRING Value );
847 GetProcAddress( GetNtDll(),
"RtlSetEnvironmentVariable" );
850 if ( !ok ) SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
854 PUNICODE_STRING puVal = NULL;
858 puVal = (PUNICODE_STRING) uValue;
870 static NTSTATUS (NTAPI *_RtlQueryEnvironmentVariable)(
871 PWSTR Environment, PUNICODE_STRING Name, PUNICODE_STRING Value );
873 if (!_RtlQueryEnvironmentVariable) (FARPROC&)_RtlQueryEnvironmentVariable =
874 GetProcAddress( GetNtDll(),
"RtlQueryEnvironmentVariable_U" );
876 bool ok = (_RtlQueryEnvironmentVariable != NULL);
877 if ( !ok ) SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
880 ok = (ccValBuf != NULL);
881 if ( !ok ) SetLastError( ERROR_INVALID_PARAMETER );
885 UNICODE_STRING uValue = { 0, USHORT( *ccValBuf *
WCHAR_SIZE ), NULL };
893 uValue.Buffer = Value;
895 uValue.Buffer = *ccValBuf ?
mem_AllocWStr( *ccValBuf ) : NULL;
897 NTSTATUS rc = _RtlQueryEnvironmentVariable( pwEnv, uName, &uValue );
902 UINT ccVal = uValue.Length /
WCHAR_SIZE, ccUni = ccVal;
903 if (uValue.MaximumLength > uValue.Length) ++ccUni;
908 else WideCharToMultiByte(
909 CP_ACP, 0, uValue.Buffer, ccUni, Value, *ccValBuf, NULL, NULL
911 if ( *ccValBuf )
mem_Free( uValue.Buffer );
914 if ( ccVal ) ccVal++;
926 SetLastError( ERROR_INVALID_PARAMETER );
929 UINT addLen = (UINT)_tcslen( Addendum );
935 valueLen = ok ? addLen : 0;
941 UINT bufLen = valueLen + addLen + 2;
944 if ( !valueBuf ) valueLen = 0;
954 #ifndef _UNICODE // DeduplicateCharSeparatedText is non-unicode only.. 955 if ( Sep ) valueLen =
960 if ( !ok ) valueLen = 0;
969 #endif//ndef NO_WINTERNAL 987 static const WORD PE_SIGN =
WORD(
'EP');
988 static const WORD PE_SIGN = *(
PWORD)
"PE";
989 #else // new neat way.. 997 if (!Hdr) SetLastError( ERROR_INVALID_PARAMETER );
1000 IMAGE_DOS_HEADER DosHdr;
1001 #define FHDR_SIZE sizeof(Hdr->FileHeader) 1002 #define OPTHDR_SIZE sizeof(Hdr->OptionalHeader) 1004 TCHAR name[ MAX_PATH ];
1007 GetModuleFileName( NULL, name,
dimof(name) );
1010 HANDLE hFile = CreateFile(
1011 ExeName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL
1016 ZeroMemory( &DosHdr,
sizeof(DosHdr) );
1017 ok = (
BlockRead( hFile, &DosHdr,
sizeof(DosHdr) ) ==
sizeof(DosHdr));
1018 if (ok) ok = (DosHdr.e_magic == MZ_SIGN);
1019 if (ok) ok = (DosHdr.e_lfanew > 0);
1020 if (ok) ok =
Seek( hFile, DosHdr.e_lfanew, FILE_BEGIN );
1021 if (ok) ok = (
BlockRead( hFile, &Hdr->Signature, 4 ) == 4);
1022 if (ok) ok = (LOWORD( Hdr->Signature ) == PE_SIGN);
1026 if (!ok) memset( &Hdr->FileHeader, 0,
FHDR_SIZE );
1028 if (ok && getOptHdr)
1030 ok = (Hdr->FileHeader.SizeOfOptionalHeader > 0);
1032 if (!ok) memset( &Hdr->OptionalHeader, 0,
OPTHDR_SIZE );
1034 CloseHandle( hFile );
1044 IMAGE_NT_HEADERS Hdr;
IF_DEBUG( memset( &Hdr, 0,
sizeof(Hdr) ));
1046 return ok ? Hdr.FileHeader.Machine : 0;
1051 IMAGE_NT_HEADERS Hdr;
IF_DEBUG( memset( &Hdr, 0,
sizeof(Hdr) ));
1055 ok = (Hdr.OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC);
1065 PIMAGE_DOS_HEADER pDos = (PIMAGE_DOS_HEADER) hInst;
1066 if (pDos->e_lfanew > 0)
1068 PIMAGE_NT_HEADERS pHdr = PIMAGE_NT_HEADERS(
PBYTE(pDos) + pDos->e_lfanew );
1069 if (LOWORD( pHdr->Signature ) == PE_SIGN) mach = pHdr->FileHeader.Machine;
1078 return (mach == IMAGE_FILE_MACHINE_AMD64 || mach == IMAGE_FILE_MACHINE_IA64);
1085 return (mach == IMAGE_FILE_MACHINE_I386);
1091 #ifndef IMAGE_FILE_MACHINE_ALPHA 1092 #define IMAGE_FILE_MACHINE_ALPHA 0x0184 // Alpha_AXP 1093 #define IMAGE_FILE_MACHINE_ALPHA64 0x0284 // ALPHA64, AXP64 1095 #ifndef IMAGE_FILE_MACHINE_R3000 1096 #define IMAGE_FILE_MACHINE_R3000 0x0162 // MIPS little-endian, 0x160 big-endian 1097 #define IMAGE_FILE_MACHINE_R4000 0x0166 // MIPS little-endian 1098 #define IMAGE_FILE_MACHINE_R10000 0x0168 // MIPS little-endian 1106 default: smach = _T(
"Undefined");
break;
1107 case IMAGE_FILE_MACHINE_UNKNOWN: smach = _T(
"Unknown");
break;
1108 case IMAGE_FILE_MACHINE_I386: smach = _T(
"32 bit (x86)");
break;
1109 case IMAGE_FILE_MACHINE_AMD64: smach = _T(
"64 bit (x64)");
break;
1110 case IMAGE_FILE_MACHINE_IA64: smach = _T(
"64 bit (IA64)");
break;
1112 case IMAGE_FILE_MACHINE_POWERPC: smach = _T(
"PowerPC");
break;
1113 case IMAGE_FILE_MACHINE_POWERPCFP: smach = _T(
"PowerPC/FP");
break;
1122 case IMAGE_FILE_MACHINE_WCEMIPSV2: smach = _T(
"Mips WCEv2");
break;
1123 case IMAGE_FILE_MACHINE_MIPS16: smach = _T(
"Mips 16");
break;
1124 case IMAGE_FILE_MACHINE_MIPSFPU: smach = _T(
"Mips/Fpu");
break;
1125 case IMAGE_FILE_MACHINE_MIPSFPU16: smach = _T(
"Mips/Fpu16");
break;
1127 #if 0 // Other (mobile devices) 1128 case IMAGE_FILE_MACHINE_SH3: smach = _T(
"SH3/le");
break;
1129 case IMAGE_FILE_MACHINE_SH3DSP: smach = _T(
"SH3/dsp");
break;
1130 case IMAGE_FILE_MACHINE_SH3E: smach = _T(
"SH3E");
break;
1131 case IMAGE_FILE_MACHINE_SH4: smach = _T(
"SH4/le");
break;
1132 case IMAGE_FILE_MACHINE_SH5: smach = _T(
"SH5");
break;
1133 case IMAGE_FILE_MACHINE_ARM: smach = _T(
"ARM/le");
break;
1134 case IMAGE_FILE_MACHINE_THUMB: smach = _T(
"Thumb");
break;
1135 case IMAGE_FILE_MACHINE_AM33: smach = _T(
"AM33");
break;
1136 case IMAGE_FILE_MACHINE_TRICORE: smach = _T(
"TriCore");
break;
1137 case IMAGE_FILE_MACHINE_CEF: smach = _T(
"CEF");
break;
1138 case IMAGE_FILE_MACHINE_EBC: smach = _T(
"EFI/BC");
break;
1139 case IMAGE_FILE_MACHINE_M32R: smach = _T(
"M32R/le");
break;
1140 case IMAGE_FILE_MACHINE_CEE: smach = _T(
"CEE");
break;
1146 #ifndef IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION 1147 #define IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION 16 1155 default: ss = _T(
"Undef");
break;
1156 case IMAGE_SUBSYSTEM_UNKNOWN: ss = _T(
"?");
break;
1157 case IMAGE_SUBSYSTEM_NATIVE: ss = _T(
"Native");
break;
1158 case IMAGE_SUBSYSTEM_WINDOWS_GUI: ss = _T(
"GUI");
break;
1159 case IMAGE_SUBSYSTEM_WINDOWS_CUI: ss = _T(
"Con");
break;
1160 case IMAGE_SUBSYSTEM_OS2_CUI: ss = _T(
"OS2");
break;
1161 case IMAGE_SUBSYSTEM_POSIX_CUI: ss = _T(
"Posix");
break;
1162 case IMAGE_SUBSYSTEM_NATIVE_WINDOWS: ss = _T(
"Drv9x");
break;
1163 case IMAGE_SUBSYSTEM_WINDOWS_CE_GUI: ss = _T(
"WinCE");
break;
1164 case IMAGE_SUBSYSTEM_EFI_APPLICATION: ss = _T(
"EFI App");
break;
1165 case IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER: ss = _T(
"EFI Boot");
break;
1166 case IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER: ss = _T(
"EFI Drv");
break;
1167 case IMAGE_SUBSYSTEM_EFI_ROM: ss = _T(
"EFI ROM");
break;
1168 case IMAGE_SUBSYSTEM_XBOX: ss = _T(
"XBox");
break;
UINT MultiSzLengthW(WCSTR MultiSz)
UINT MultiSzLengthA(ACSTR MultiSz)
HANDLE CloseHandleEx(HANDLE Hnd)
_NTFN_EXTERN VOID _RtlDestroyEnvironment(IN PWSTR Environment)
bool ReadNTHeaders(CSTR ExeName, IMAGE_NT_HEADERS *Hdr, bool getOptHdr)
HANDLE CheckHandle(HANDLE Hnd)
FILETIME AddFiletime(FILETIME Time, const FILETIME Add)
UINT DeduplicatePathStr(TSTR Path)
bool GetEnvironmentSize(WSTR pwEnv, PUINT pSize, PUINT pUsed)
bool IsBadReadWritePtr(const PVOID address, UINT_PTR size)
UINT DeduplicateCharSepText(INOUT ASTR Text, CHAR Separator, bool caseSens, bool emitSorted)
CSTR GetMachineStr(WORD Machine)
HANDLE GetCurrentThreadHandle()
bool WaitFor(HANDLE hObj, DWORD msWait)
CSTR LocalAtomName(ATOM Atom)
bool SetEnvironmentVar(OPTIO WSTR *pwEnv, IN CSTR Name, IN CSTR Value)
WSTR CloneEnvironment(OPTOUT PUINT pLength, OPTOUT PUINT pUsed)
#define IMAGE_FILE_MACHINE_R10000
#define BEGIN_STRSAFE_OVERRIDE
#define IMAGE_FILE_MACHINE_ALPHA64
#define END_NAMESPACE(name)
void __cdecl DPrint(int Level, CSTR Fmt,...)
FILETIME MakeDateTime(WORD Year, WORD Month, WORD Day, WORD Hr, WORD Min, WORD Sec)
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)
CSTR GlobalAtomName(ATOM Atom)
HANDLE GetCurrentProcessHandle()
UINT GetProcDllData(HANDLE hProcess, WCSTR DllName, OUT PLDR_MODULE pModule, bool Localize)
WORD GetInstanceTargetMachine(HINSTANCE hInst)
WORD GetTargetMachine(CSTR ExeName)
bool operator >(FILETIME const &A, FILETIME const &B)
#define IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION
WSTR FreeEnvironment(WSTR Env)
#define IMAGE_FILE_MACHINE_ALPHA
END_STRSAFE_OVERRIDE HANDLE GlobalUnlockedHandle(PVOID Ptr, PUINT pCount)
UINT GlobalPurgeAtom(CSTR Name)
SHORT GetProcDLLRefCount(HANDLE hProcess, WCSTR DllName)
UINT PrependString(INOUT TSTR String, UINT ccBuf, OPTIN TCHAR Sep, CSTR Prolog)
_NTFN_EXTERN NTSTATUS _RtlSetEnvironmentVariable(IN PWSTR *Environment, IN PUNICODE_STRING Name, IN PUNICODE_STRING Value)
WSTR GlobalAllocStrW(UINT Count)
#define IMAGE_FILE_MACHINE_R3000
HMODULE GetOrLoadModule(CSTR modName)
UINT AppendString(INOUT TSTR String, UINT ccBuf, OPTIN TCHAR Sep, CSTR Epilog)
BOOL(WINAPI *SysImgList::Shell_GetImageLists)(HIMAGELIST *pimlLarge
void * mem_Free(void *pBlk)
SYSTEMTIME * SystemTimeToLocalTime(SYSTEMTIME *Time)
bool operator >=(FILETIME const &A, FILETIME const &B)
BEGIN_STRSAFE_OVERRIDE ASTR GlobalDupStrA(ACSTR Str, bool isMulti)
WSTR mem_AllocWStr(WORD nChar)
bool SetLastErrorFromNtStatus(NTSTATUS Status)
bool operator<=(FILETIME const &A, FILETIME const &B)
CSTR SysErrorMsg(DWORD Err=0, TSTR Buf=NULL, UINT Length=0)
HANDLE CloseCapturedProcess(IN HANDLE hProc, IN LPSTARTUPINFO pSi, IN PHANDLE pRdHnd, IN PHANDLE pWrHnd, IN PHANDLE pErrHnd)
const FILETIME NullFileTime
SECURITY_ATTRIBUTES DefSec
UINT ModifyEnvironmentVar(WSTR *pwEnv, BYTE Option, CSTR Name, CSTR Addendum, TCHAR Sep)
HMODULE GetProcDLLHandle(HANDLE hProcess, WCSTR DllName)
ASTR GlobalAllocStrA(UINT Count)
SYSTEMTIME * LocalTimeToSystemTime(SYSTEMTIME *Time)
UINT BlockRead(HANDLE hFile, PVOID Buf, UINT nBytes)
bool GetEnvironmentVar(OPTIN WSTR pwEnv, IN CSTR Name, OUT TSTR Value, INOUT PUINT ccValBuf)
Debug and error handling support.
_NTFN_EXTERN NTSTATUS _RtlCreateEnvironment(IN BOOLEAN Clone, OUT PWSTR *Environment)
FILETIME FileTimeToLocalTime(FILETIME utc)
CSTR GetSubSystemStr(WORD SubSys)
#define BEGIN_NAMESPACE(name)
Common include; Added types, small "ubiquitous" utilities, et c.
bool operator<(FILETIME const &A, FILETIME const &B)
FILETIME Now(eTimeType Domain=LOCAL_TIME)
bool Is32BitInstance(HINSTANCE hInst)
HMODULE LoadProcLibrary(HANDLE hProc, LPCSTR DllPathName, DWORD msWait)
FILETIME AddTime(IN FILETIME Time, SHORT Hr, SHORT Min, SHORT Sec, SHORT mSec)
bool Is64BitInstance(HINSTANCE hInst)
bool operator==(FILETIME const &A, FILETIME const &B)
WSTR GlobalDupStrW(WCSTR Str, bool isMulti)
bool Is64BitExecutable(CSTR ExeName)
#define ROUND_UP2(x, chunk)
ModifyEnvironmentVar() prepends the Addendum.
BOOL UnloadProcLibrary(HANDLE hProc, HMODULE hLib, DWORD msWait)
#define NT_SUCCESS(Status)
HANDLE Launch(CSTR exePath, CSTR cmdLn, CSTR startDir, int iShow, DWORD Flags)
#define END_STRSAFE_OVERRIDE
HANDLE CreateCapturedProcess(IN CSTR cmdLn, IN LPSTARTUPINFO si, IN DWORD Flags, OPTOUT PHANDLE pRdHnd, OPTOUT PHANDLE pWrHnd, OPTOUT PHANDLE pErrHnd, OPTOUT PHANDLE phThread)
bool Seek(HANDLE hFile, LONG Offs, DWORD How)
bool __forceinline IsString(CSTR Str)
HANDLE TerminateCapturedProcess(IN HANDLE hProc, IN LPSTARTUPINFO pSi, IN PHANDLE pRdHnd, IN PHANDLE pWrHnd, IN PHANDLE pErrHnd, IN UINT retCode)
bool operator !=(FILETIME const &A, FILETIME const &B)
#define IMAGE_FILE_MACHINE_R4000