월별 글 목록: 2005년 4월월

드라이버 컴파일시 sym파일생성

드라이버 컴파일 때 SOURCES 파일에

USE_MAPSYM=1

를 추가 시키면

컴파일 후에 map파일과 sym파일이 생성이 된다.

다음은 DDK 문서의 레퍼런스 내용이다.

USE_MAPSYM
Use the USE_MAPSYM macro if you want to generate .sym symbol files in addition to the .pdb symbol files.

Use the following syntax:

USE_MAPSYM=1

GetSystemVersion

MSDN Platform SDK의 “Getting the System Version” 참조

#define WINDOWS31 300
#define WINDOWS95 400
#define WINDOWS95OSR2 402
#define WINDOWS98 410
#define WINDOWS98SE 412
#define WINDOWSME 490

#define WINDOWSNT 351
#define WINDOWSNTWORKSTATION 401
#define WINDOWSNTSERVER 403
#define WINDOWS2000 500
#define WINDOWS2000PRO 501
#define WINDOWS2000SERVER 502
#define WINDOWS2000AVSERVER 503
#define WINDOWSXP 510
#define WINDOWSXPPRO 511
#define WINDOWSXPHOME 512
#define WINDOWS2003SERVER 520

ULONG GetSystemVersion()
{
OSVERSIONINFOEX OSVerInfo;
BOOL bOsVersionInfoEx;
ULONG SystemVersion = 0;

ZeroMemory(&OSVerInfo, sizeof(OSVERSIONINFOEX));
OSVerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &OSVerInfo)) )
{
OSVerInfo.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
if(!GetVersionEx((OSVERSIONINFO *) &OSVerInfo))
{
return 0;
}
}
switch(OSVerInfo.dwPlatformId)
{
case VER_PLATFORM_WIN32_NT:
if(OSVerInfo.dwMajorVersion == 5 && OSVerInfo.dwMinorVersion == 2)
{
SystemVersion = WINDOWS2003SERVER;
}
if(OSVerInfo.dwMajorVersion == 5 && OSVerInfo.dwMinorVersion == 1)
{
SystemVersion = WINDOWSXP;
}
if(OSVerInfo.dwMajorVersion == 5 && OSVerInfo.dwMinorVersion == 0)
{
SystemVersion = WINDOWS2000;
}
if(OSVerInfo.dwMajorVersion <= 4)
{
SystemVersion = WINDOWSNT;
}
if(bOsVersionInfoEx)
{
if(OSVerInfo.wProductType == VER_NT_WORKSTATION)
{
if(OSVerInfo.dwMajorVersion == 4)
{
SystemVersion = WINDOWSNTWORKSTATION;
}
else if(OSVerInfo.wSuiteMask & VER_SUITE_PERSONAL)
{
SystemVersion = WINDOWSXPHOME;
}
else
{
SystemVersion = WINDOWSXPPRO;
}
}

else if(OSVerInfo.wProductType == VER_NT_SERVER)
{
if(OSVerInfo.dwMajorVersion == 5 && OSVerInfo.dwMinorVersion == 2)
{
if(OSVerInfo.wSuiteMask & VER_SUITE_DATACENTER)
{
SystemVersion = WINDOWS2003SERVER;

}
else if(OSVerInfo.wSuiteMask & VER_SUITE_ENTERPRISE)
{
SystemVersion = WINDOWS2003SERVER;
}
else if(OSVerInfo.wSuiteMask == VER_SUITE_BLADE)
{
SystemVersion = WINDOWS2003SERVER;
}
else
{
SystemVersion = WINDOWS2003SERVER;
}
}
else if(OSVerInfo.dwMajorVersion == 5 && OSVerInfo.dwMinorVersion == 0)
{
if(OSVerInfo.wSuiteMask & VER_SUITE_DATACENTER)
{
SystemVersion = WINDOWS2000SERVER;
}
else if(OSVerInfo.wSuiteMask & VER_SUITE_ENTERPRISE)
{
SystemVersion = WINDOWS2000AVSERVER;

}
else
{
SystemVersion = WINDOWS2000SERVER;
}
}
else
{
if(OSVerInfo.wSuiteMask & VER_SUITE_ENTERPRISE)
{
SystemVersion = WINDOWSNT;
}
else
{
SystemVersion = WINDOWSNT;
}
}
}
}
else
{
HKEY hKey;
#define BUFSIZE 512
char szProductType[BUFSIZE];
DWORD dwBufLen=BUFSIZE;
LONG lRet;

lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
“SYSTEM\\CurrentControlSet\\Control\\ProductOptions”,
0,
KEY_QUERY_VALUE,
&hKey);
if(lRet != ERROR_SUCCESS)
{
return 0;
}
lRet = RegQueryValueEx(hKey,
“ProductType”,
NULL,
NULL,
(LPBYTE)szProductType,
&dwBufLen);
if((lRet != ERROR_SUCCESS) || (dwBufLen > BUFSIZE))
{
return 0;
}
RegCloseKey(hKey);
if(lstrcmpi(“WINNT”, szProductType) == 0)
{
SystemVersion = WINDOWSNTWORKSTATION;
}
if(lstrcmpi(“LANMANNT”, szProductType) == 0)
{
SystemVersion = WINDOWSNTSERVER;
}
if(lstrcmpi(“SERVERNT”, szProductType) == 0)
{
SystemVersion = WINDOWSNTSERVER;
}
}
if(OSVerInfo.dwMajorVersion == 4 &&
lstrcmpi(OSVerInfo.szCSDVersion, “Service Pack 6”) == 0)
{
HKEY hKey;
LONG lRet;
lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
“SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\Q246009”,
0,
KEY_QUERY_VALUE,
&hKey);
if(lRet == ERROR_SUCCESS)
{
}
else
{
}
RegCloseKey(hKey);
}
else
{
}

break;
case VER_PLATFORM_WIN32_WINDOWS:
if(OSVerInfo.dwMajorVersion == 4 && OSVerInfo.dwMinorVersion == 0)
{
SystemVersion = WINDOWS95;
if(OSVerInfo.szCSDVersion[1] == ‘C’ || OSVerInfo.szCSDVersion[1] == ‘B’)
{
SystemVersion = WINDOWS95OSR2;
}
}
if(OSVerInfo.dwMajorVersion == 4 && OSVerInfo.dwMinorVersion == 10)
{
SystemVersion = WINDOWS98;
if(OSVerInfo.szCSDVersion[1] == ‘A’)
{
SystemVersion = WINDOWS98SE;
}
}
if(OSVerInfo.dwMajorVersion == 4 && OSVerInfo.dwMinorVersion == 90)
{
SystemVersion = WINDOWSME;
}
break;

case VER_PLATFORM_WIN32s:
SystemVersion = WINDOWS31;
break;
}
return SystemVersion;
}