018
26.08.2003, 17:57 Uhr
Spacelord
Hoffnungsloser Fall
|
@deadbeef: Hier ist mal nen kleiner Ausschnitt aus der C Runtime von Windows. Ist eine der absoluten Basisdateien!
C++: |
/*** *heapinit.c - Initialze the heap * * Copyright (c) 1989-1998, Microsoft Corporation. All rights reserved. * *Purpose: * *******************************************************************************/
#ifdef WINHEAP
#include <cruntime.h> #include <malloc.h> #include <stdlib.h> #include <winheap.h>
HANDLE _crtheap;
/* * Dummy definition of _amblksiz. Included primarily so the dll will build * without having to change crtlib.c (there is an access function for _amblksiz * defined in crtlib.c). */ unsigned int _amblksiz = BYTES_PER_PARA;
int __active_heap;
void __cdecl _GetLinkerVersion(LinkerVersion * plv) { PIMAGE_DOS_HEADER pidh; PIMAGE_NT_HEADERS pinh;
plv->dw = 0; pidh = (PIMAGE_DOS_HEADER) GetModuleHandle(NULL);
if ( pidh->e_magic != IMAGE_DOS_SIGNATURE || pidh->e_lfanew == 0) return;
pinh = (PIMAGE_NT_HEADERS)(((PBYTE)pidh) + pidh->e_lfanew);
plv->bverMajor = pinh->OptionalHeader.MajorLinkerVersion; plv->bverMinor = pinh->OptionalHeader.MinorLinkerVersion; }
/*** *__heap_select() - Choose from the V6, V5 or system heaps * *Purpose: * Check OS, environment and build bits to determine appropriate * small-block heap for the app. * *Entry: * <void> *Exit: * Returns __V6_HEAP, __V5_HEAP or __SYSTEM_HEAP * *Exceptions: * none * *******************************************************************************/
int __cdecl __heap_select(void) { char env_heap_select_string[(_MAX_PATH+5)*16]; char env_app_name[_MAX_PATH]; char *env_heap_type = NULL; char *cp; int heap_choice; LinkerVersion lv; OSVERSIONINFO osvi;
// First, check the OS for NT >= 5.0 osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if ( GetVersionEx(&osvi) ) if ( (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) && (osvi.dwMajorVersion >= 5) ) return __SYSTEM_HEAP;
// Second, check the envrionment variable override if (GetEnvironmentVariableA(__HEAP_ENV_STRING, env_heap_select_string, sizeof(env_heap_select_string))) { for (cp = env_heap_select_string; *cp; ++cp) if ('a' <= *cp && *cp <= 'z') *cp += 'A' - 'a'; if (!strncmp(__GLOBAL_HEAP_SELECTOR,env_heap_select_string,sizeof(__GLOBAL_HEAP_SELECTOR)-1)) env_heap_type = env_heap_select_string; else { GetModuleFileName(NULL,env_app_name,sizeof(env_app_name)); for (cp = env_app_name; *cp; ++cp) if ('a' <= *cp && *cp <= 'z') *cp += 'A' - 'a'; env_heap_type = strstr(env_heap_select_string,env_app_name); } if (env_heap_type) { if (env_heap_type = strchr(env_heap_type,',')) { cp = ++env_heap_type; while (*cp) { if (*cp == ';') *cp = 0; else cp++; } heap_choice = (int)strtol(env_heap_type, NULL, 10); if ( (heap_choice == __V5_HEAP) || (heap_choice == __V6_HEAP) || (heap_choice == __SYSTEM_HEAP) ) return heap_choice; } } }
// Third, check the build bits in the app; apps built with tools >= VC++ 6.0 // will get the V6 heap, apps built with older tools will get the V5 heap
_GetLinkerVersion(&lv); if (lv.bverMajor >= 6) return __V6_HEAP; else return __V5_HEAP;
}
/***
|
Wenn du nen popeliges new aufrufen willst kommt diese und 20 andere Dateien zu Einsatz. Das ganze ist (mal ganz abgesehen von den Api-Aufrufen) so vollgepackt mit OS spezifischem Code dass du damit ohne Portierung auf deinem eigenen OS nichts(!) anfangen kannst. Durch die gegenseitigen Abhängigkeiten der einzelnen Dateien wirst du im Endeffekt trotzdem die komplette lib mitlinken.
MfG Spacelord -- .....Ich mach jetzt nämlich mein Jodeldiplom.Dann hab ich endlich was Eigenes. |