Clean memory
// Swaps the process out of physical RAM memory SetProcessWorkingSetSize(GetCurrentProcess(), (SIZE_T)-1, (SIZE_T)-1);
Можно ещё делать так, когда память процесса превышает некую “норму”:
EmptyWorkingSet(GetCurrentProcess());
// Swaps the process out of physical RAM memory SetProcessWorkingSetSize(GetCurrentProcess(), (SIZE_T)-1, (SIZE_T)-1);
Можно ещё делать так, когда память процесса превышает некую “норму”:
EmptyWorkingSet(GetCurrentProcess());
#pragma warning – enables selective modification of the behavior of compiler warning messages.
Additional “pragma warning” parameter is suppress – pushes the current state of the pragma on the stack, disables the specified warning for the next line, and then pops the warning stack so that the pragma state is reset.
Also __pragma() can be used instead of #pragma which allows it to use inside macros:
#define __const_cond( c ) \ __pragma(warning(push)) \ __pragma(warning(disable:4127)) \ ( c ) \ __pragma(warning(pop))
The Sysinternals web site was created in 1996 by Mark Russinovich and Bryce Cogswell to host their advanced system utilities and technical information. Microsoft acquired Sysinternals in July, 2006. Whether you’re an IT Pro or a developer, you’ll find Sysinternals utilities to help you manage, troubleshoot and diagnose your Windows systems and applications. If you have a question about a tool or how to use them, please visit the Sysinternals Forum for answers and help from other users and our moderators.
Sysinternals Live is a service that enables you to execute Sysinternals tools directly from the Web without hunting for and manually downloading them. Simply enter a tool’s Sysinternals Live path into Windows Explorer or a command prompt as http://live.sysinternals.com/<toolname> or \\live.sysinternals.com\tools\<toolname>.
You can view the entire Sysinternals Live tools directory in a browser at live.sysinternals.com.
Or you can map the server to your drive:
net use y: \\live.sysinternals.com\tools
CppWindowsCommonControls contains simple examples of how to create common controls defined in comctl32.dll. The controls include Animation, ComboBoxEx, Updown, Header, MonthCal, DateTimePick, ListView, TreeView, Tab, Tooltip, IP Address, Statusbar, Progress Bar, Toolbar, Trackbar, and SysLink.
Visual Studio 2008 has supports “Enable Instruction Functions” options (see a project settings -> C/C++ -> Optimization). Note that this option can enlarge code.
Also memcpy function implementation has written with using sse2 (movdqa).
int CopyMemSSE4(int* piDst, int* piSrc, unsigned long SizeInBytes) { // Initialize pointers to start of the USWC memory _asm { mov esi, piSrc mov edx, piSrc // Initialize pointer to end of the USWC memory add edx, SizeInBytes // Initialize pointer to start of the cacheable WB buffer mov edi, piDst // Start of Bulk Load loop inner_start: // Load data from USWC Memory using Streaming Load MOVNTDQA xmm0, xmmword ptr [esi] MOVNTDQA xmm1, xmmword ptr [esi+16] MOVNTDQA xmm2, xmmword ptr [esi+32] MOVNTDQA xmm3, xmmword ptr [esi+48] // Copy data to buffer MOVDQA xmmword ptr [edi], xmm0 MOVDQA xmmword ptr [edi+16], xmm1 MOVDQA xmmword ptr [edi+32], xmm2 MOVDQA xmmword ptr [edi+48], xmm3 // Increment pointers by cache line size and test for end of loop add esi, 040h add edi, 040h cmp esi, edx jne inner_start } // End of Bulk Load loop return 0; } #define DATA_SIZE 0x01000000 int main(int argc, char* argv[]) { int *piSrc = NULL; int *piDst = NULL; unsigned long dwDataSizeInBytes = sizeof(int) * DATA_SIZE; piSrc = (int *)_aligned_malloc(dwDataSizeInBytes, dwDataSizeInBytes); piDst = (int *)_aligned_malloc(dwDataSizeInBytes, dwDataSizeInBytes); memset(piSrc, 255, dwDataSizeInBytes); memset(piDst, 0, dwDataSizeInBytes); CopyMemSSE4(piDst, piSrc, dwDataSizeInBytes); _aligned_free(piSrc); _aligned_free(piDst); }
Additional links:
The CheckTokenMembership function determines whether a specified security identifier (SID) is enabled in an access token.
/* Routine Description: This routine returns TRUE if the caller's process is a member of the Administrators local group. Caller is NOT expected to be impersonating anyone and is expected to be able to open its own process and process token. Arguments: None. Return Value: TRUE - Caller has Administrators local group. FALSE - Caller does not have Administrators local group. */ BOOL IsUserAdmin(void) { BOOL bResult; SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY; PSID AdministratorsGroup; bResult = AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &AdministratorsGroup); if(bResult) { if(!CheckTokenMembership(NULL, AdministratorsGroup, &bResult)) { bResult = FALSE; } FreeSid(AdministratorsGroup); } return(bResult); }
stdint.h is a header file in the C standard library introduced in the C99 standard library section 7.18 to allow programmers to write more portable code by providing a set of typedefs that specify exact-width integer types, together with the defined minimum and maximum allowable values for each type, using macros. This header is particularly useful for embedded programming which often involves considerable manipulation of hardware specific I/O registers requiring integer data of fixed widths, specific locations and exact alignments. stdint.h (for C), and stdint.h and cstdint (for C++).
stdint.h defines:
int8_t
int16_t
int32_t
uint8_t
uint16_t
uint32_t
stdint.h is not shipped with older C++ compilers and Visual Studio C++ products prior to Visual Studio 2010.
The Low Level Virtual Machine (LLVM) is a compiler infrastructure, written in C++, which is designed for compile-time, link-time, run-time, and “idle-time” optimization of programs written in arbitrary programming languages. Originally implemented for C/C++, the language-independent design (and the success) of LLVM has since spawned a wide variety of front ends, including Objective-C, Fortran, Ada, Haskell, Java bytecode, Python, Ruby, ActionScript, GLSL, and others.
LLVM can provide the middle layers of a complete compiler system, taking intermediate form (IF) code from a compiler and outputting an optimized IF that can then be converted and linked into machine-dependent assembler code for a target platform. LLVM can accept the IF from the GCC toolchain, allowing it to be used with a wide array of existing compilers written for that project.
LLVM can also generate relocatable machine code at compile-time or link-time or even binary machine code at run-time.
LLVM supports a language-independent instruction set and type system. Each instruction is in static single assignment form (SSA), meaning that each variable (called a typed register) is assigned once and is frozen. This helps simplify the analysis of dependencies among variables. LLVM allows code to be compiled statically, as it is under the traditional GCC system, or left for late-compiling from the IF to machine code in a just-in-time compiler (JIT) in a fashion similar to Java. The type system consists of basic types such as integers or floats and five derived types: pointers, arrays, vectors, structures, and functions. A type construct in a concrete language can be represented by combining these basic types in LLVM. For example, a class in C++ can be represented by a combination of structures, functions and arrays of function pointers.
Additional links:
Wireshark is the world’s foremost network protocol analyzer, and is the de facto (and often de jure) standard across many industries and educational institutions.
bin\bjam.exe –build-dir=”C:\Dev\Libs\boost\build-boost” –toolset=msvc –build-type=complete stage