pidgen.dll

This commit is contained in:
Andrew 2023-04-05 15:26:17 +03:00
parent e21f32ab11
commit 5c8a450c05
54 changed files with 4052 additions and 2 deletions

View File

@ -323,7 +323,7 @@ void generateKey(unsigned char *pKey, EC_GROUP *eCurve, EC_POINT *generator, BIG
unsigned char md[SHA_DIGEST_LENGTH], buf[FIELD_BYTES], t[4];
unsigned long hash[1];
/* h = (fist 32 bits of SHA1(pRaw || r.x, r.y)) >> 4 */
// h = (First-32(SHA1(pRaw, r.x, r.y)) >> 4
SHA1_Init(&hContext);
// Chop Raw Product Key into 4 bytes.
@ -565,7 +565,6 @@ int main() {
pRaw[0] <<= 1;
for (int i = 0; i < 10; i++) {
cprintf("Product Key %d:\n", 0x08, i + 1);

8
pidgen/.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

8
pidgen/.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/pidgen.iml" filepath="$PROJECT_DIR$/.idea/pidgen.iml" />
</modules>
</component>
</project>

8
pidgen/.idea/pidgen.iml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="CPP_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

BIN
pidgen/00000.pub Normal file

Binary file not shown.

BIN
pidgen/00001.pub Normal file

Binary file not shown.

BIN
pidgen/00002.pub Normal file

Binary file not shown.

BIN
pidgen/00003.pub Normal file

Binary file not shown.

BIN
pidgen/00008.pub Normal file

Binary file not shown.

BIN
pidgen/00009.pub Normal file

Binary file not shown.

BIN
pidgen/00010.pub Normal file

Binary file not shown.

BIN
pidgen/00018.pub Normal file

Binary file not shown.

BIN
pidgen/00019.pub Normal file

Binary file not shown.

BIN
pidgen/00040.pub Normal file

Binary file not shown.

BIN
pidgen/00041.pub Normal file

Binary file not shown.

BIN
pidgen/00042.pub Normal file

Binary file not shown.

BIN
pidgen/00043.pub Normal file

Binary file not shown.

BIN
pidgen/00044.pub Normal file

Binary file not shown.

BIN
pidgen/00045.pub Normal file

Binary file not shown.

BIN
pidgen/00046.pub Normal file

Binary file not shown.

BIN
pidgen/00047.pub Normal file

Binary file not shown.

51
pidgen/ccrc32.h Normal file
View File

@ -0,0 +1,51 @@
/*++
Copyright (c) 1998-1999, Microsoft Corporation
Module Name:
CCrc32.h
Abstract:
--*/
#ifndef CCRC32_H
#define CCRC32_H
#ifndef __WINDOWS_H
#include <windows.h>
#endif
// Used Definitions Declarations
#define CCRC32_CLASSID 0x13420808L
#define CRC32_POLYNOMIAL 0xEDB88320
// Class Declaration
class CCrc32
{
public:
CCrc32();
virtual ~CCrc32();
public:
ULONG CalculateBlockCRC( LPVOID lpvBlock, INT nBlockLength );
public:
ULONG uClassID;
private:
VOID InitialiseCRCTable();
private:
ULONG m_uCRC32Table[ 256 ];
};
#endif

140
pidgen/chardwar.h Normal file
View File

@ -0,0 +1,140 @@
/*++
Copyright (c) 1998-1999, Microsoft Corporation
Module Name:
CHardwar.h
Abstract:
--*/
#ifndef CHARDWARE_H
#define CHARDWARE_H
#ifndef __WINDOWS_H
#include <windows.h>
#endif
// Used Definitions Declarations
#define CHARDWARE_CLASSID 0x13530808L
#define BIOS_DIGIT 0
#define HD_SERIAL_DIGIT 1
#define TOTAL_RAM_DIGIT 2
#define FD_CONFIG_DIGIT 3
#define VIDEO_BIOS_DIGIT 4
#define HARDWARE_ID_SIZE 6
#define HARDWARE_GUID_SIZE 39
#define MAX_BIOS_KEY_LENGTH 2048
#define VWIN32_DIOC_DOS_INT13 4
#define FLAGS_CARRY 1
// Used Type Declarations
typedef struct _DIOC_REGISTERS
{
DWORD reg_EBX;
DWORD reg_EDX;
DWORD reg_ECX;
DWORD reg_EAX;
DWORD reg_EDI;
DWORD reg_ESI;
DWORD reg_Flags;
} DIOC_REGISTERS, *PDIOC_REGISTERS;
#pragma pack(1)
typedef struct _DEVICEPARAMS
{
BYTE dpSpecFunc;
BYTE dpDevType;
WORD dpDevAttr;
WORD dpCylinders;
BYTE dpMediaType;
WORD dpBytesPerSec;
BYTE dpSecPerClust;
WORD dpResSectors;
BYTE dpFATs;
WORD dpRootDirEnts;
WORD dpSectors;
BYTE dpMedia;
WORD dpFATsecs;
WORD dpSecPerTrack;
WORD dpHeads;
DWORD dpHiddenSecs;
DWORD dpHugeSectors;
} DEVICEPARAMS, *PDEVICEPARAMS;
#pragma pack()
// Class Declaration
class CHardware
{
public:
CHardware();
virtual ~CHardware();
public:
LPSTR GetGUID();
LPSTR GetID();
#ifdef HWID_DETAIL ////////////////////////////////////////////////////////////
DWORD GetType();
DWORD GetBiosCrc32() { return m_dwBiosCrc32; };
DWORD GetVolSer() { return m_dwVolSer; };
DWORD GetTotalRamMegs() { return m_dwTotalRamMegs; };
DWORD GetVideoBiosCrc32() { return m_dwVideoBiosCrc32; };
#endif
public:
ULONG uClassID;
private:
#ifndef _WIN64
DWORD CalculateDriveCapacity95( INT nDrive );
#endif
DWORD CalculateMemoryRegionChecksum( LPBYTE pbChecksumArea, INT nNumberBytes );
VOID SetBIOSDigit();
VOID SetFDConfigDigit();
VOID SetHDSerialDigit();
VOID SetTotalRAMDigit();
VOID SetVideoBIOSDigit();
#ifndef NO_HWID_GUID //////////////////////////////////////////////////////////
VOID CalculateHardwareGUID();
#endif ////////////////////////////////////////////////////////////////////////
#if defined(WIN32) || defined(_WIN32)
static UINT CalculateRegKeyChecksum( LPSTR lpszKey );
static DWORD CalculateDriveCapacityNT( INT nDrive );
#endif
private:
CHAR m_szHardwareID[ HARDWARE_ID_SIZE ];
#ifndef NO_HWID_GUID //////////////////////////////////////////////////////////
CHAR m_szHardwareGUID[ HARDWARE_GUID_SIZE ];
#endif ////////////////////////////////////////////////////////////////////////
#ifdef HWID_DETAIL ////////////////////////////////////////////////////////////
DWORD m_dwBiosCrc32;
DWORD m_dwVolSer;
DWORD m_dwTotalRamMegs;
DWORD m_dwVideoBiosCrc32;
#endif
};
#endif

46
pidgen/crc-32.cpp Normal file
View File

@ -0,0 +1,46 @@
/*++
Copyright (c) 1998-1999, Microsoft Corporation
Module Name:
crc-32.cpp
Abstract:
--*/
#include <windows.h>
#include "crc-32.h"
DWORD CRC_32(LPBYTE pb, DWORD cb)
{
// CRC-32 algorithm used in PKZip, AUTODIN II, Ethernet, and FDDI
// but xor out (xorot) has been changed from 0xFFFFFFFF to 0 so
// we can store the CRC at the end of the block and expect 0 to be
// the value of the CRC of the resulting block (including the stored
// CRC).
cm_t cmt = {
32, // cm_width Parameter: Width in bits [8,32].
0x04C11DB7, // cm_poly Parameter: The algorithm's polynomial.
0xFFFFFFFF, // cm_init Parameter: Initial register value.
TRUE, // cm_refin Parameter: Reflect input bytes?
TRUE, // cm_refot Parameter: Reflect output CRC?
0, // cm_xorot Parameter: XOR this to output CRC.
0 // cm_reg Context: Context during execution.
};
// Documented test case for CRC-32:
// Checking "123456789" should return 0xCBF43926
cm_ini(&cmt);
cm_blk(&cmt, pb, cb);
return cm_crc(&cmt);
}

18
pidgen/crc-32.h Normal file
View File

@ -0,0 +1,18 @@
/*++
Copyright (c) 1998-1999, Microsoft Corporation
Module Name:
crc-32.h
Abstract:
--*/
#include "crcmodel.h"
DWORD CRC_32(LPBYTE pb, DWORD cb);

75
pidgen/crc32.cpp Normal file
View File

@ -0,0 +1,75 @@
/*++
Copyright (c) 1998-1999, Microsoft Corporation
Module Name:
Crc.cpp
Abstract:
--*/
#include "Crc32.h"
CCrc32::CCrc32()
{
uClassID = CCRC32_CLASSID;
InitialiseCRCTable();
}
CCrc32::~CCrc32()
{
}
VOID CCrc32::InitialiseCRCTable()
{
INT nIndex;
INT nBitIndex;
ULONG uTableValue;
for ( nIndex = 0; nIndex < 256; nIndex++ )
{
uTableValue = nIndex;
for ( nBitIndex = 0; nBitIndex < 8; nBitIndex++ )
{
if ( ( uTableValue & 1 ) == 1 )
{
uTableValue = ( uTableValue >> 1 ) ^ CRC32_POLYNOMIAL;
} else
{
uTableValue = uTableValue >> 1;
}
}
m_uCRC32Table[ nIndex ] = uTableValue;
}
}
ULONG CCrc32::CalculateBlockCRC(LPVOID lpvBlock, INT nBlockLength)
{
INT nIndex;
LPBYTE lpbBlock;
ULONG uCRCValue;
_ASSERT( nBlockLength > 0 );
lpbBlock = (LPBYTE)lpvBlock;
uCRCValue = 0xFFFFFFFFL;
for ( nIndex = 0; nIndex < nBlockLength; nIndex++ )
{
uCRCValue = ( ( uCRCValue >> 8 ) & 0x00FFFFFFL ) ^ ( m_uCRC32Table[ ( uCRCValue ^ lpbBlock[ nIndex ] ) & 0xFFL ] );
}
uCRCValue = uCRCValue ^ 0xFFFFFFFFL;
return uCRCValue;
}

39
pidgen/crc32.h Normal file
View File

@ -0,0 +1,39 @@
/*++
Copyright (c) 1998-1999, Microsoft Corporation
Module Name:
Crc32.h
Abstract:
--*/
#ifndef CRC32_H
#define CRC32_H
#include <windows.h>
#include <string.h> // needed by compobj.h
#if defined(WIN32) || defined(_WIN32)
#include <crtdbg.h>
#else
typedef short INT;
#include <assert.h>
#define _ASSERT assert
#include <compobj.h> // needed for 16-bit build
#endif
#include "tchar.h"
#include "CCrc32.h"
#endif

143
pidgen/crcmodel.c Normal file
View File

@ -0,0 +1,143 @@
/****************************************************************************/
/* Start of crcmodel.c */
/****************************************************************************/
/* */
/* Author : Ross Williams (ross@guest.adelaide.edu.au.). */
/* Date : 3 June 1993. */
/* Status : Public domain. */
/* */
/* Description : This is the implementation (.c) file for the reference */
/* implementation of the Rocksoft^tm Model CRC Algorithm. For more */
/* information on the Rocksoft^tm Model CRC Algorithm, see the document */
/* titled "A Painless Guide to CRC Error Detection Algorithms" by Ross */
/* Williams (ross@guest.adelaide.edu.au.). This document is likely to be in */
/* "ftp.adelaide.edu.au/pub/rocksoft". */
/* */
/* Note: Rocksoft is a trademark of Rocksoft Pty Ltd, Adelaide, Australia. */
/* */
/****************************************************************************/
/* */
/* Implementation Notes */
/* -------------------- */
/* To avoid inconsistencies, the specification of each function is not */
/* echoed here. See the header file for a description of these functions. */
/* This package is light on checking because I want to keep it short and */
/* simple and portable (i.e. it would be too messy to distribute my entire */
/* C culture (e.g. assertions package) with this package. */
/* */
/****************************************************************************/
#include "crcmodel.h"
/****************************************************************************/
/* The following definitions make the code more readable. */
#define BITMASK(X) (1L << (X))
#define MASK32 0xFFFFFFFFL
#define LOCAL static
/****************************************************************************/
/* Returns the value v with the bottom b [0,32] bits reflected. */
/* Example: reflect(0x3e23L,3) == 0x3e26 */
LOCAL ulong reflect(
ulong v,
int b)
{
int i;
ulong t = v;
for (i=0; i<b; i++)
{
if (t & 1L)
v|= BITMASK((b-1)-i);
else
v&= ~BITMASK((b-1)-i);
t>>=1;
}
return v;
}
/****************************************************************************/
/* Returns a longword whose value is (2^p_cm->cm_width)-1. */
/* The trick is to do this portably (e.g. without doing <<32). */
LOCAL ulong widmask(p_cm_t p_cm)
{
return (((1L<<(p_cm->cm_width-1))-1L)<<1)|1L;
}
/****************************************************************************/
void cm_ini (p_cm_t p_cm)
{
p_cm->cm_reg = p_cm->cm_init;
}
/****************************************************************************/
void cm_nxt(p_cm_t p_cm, int ch)
{
int i;
ulong uch = (ulong) ch;
ulong topbit = BITMASK(p_cm->cm_width-1);
if (p_cm->cm_refin) uch = reflect(uch,8);
p_cm->cm_reg ^= (uch << (p_cm->cm_width-8));
for (i=0; i<8; i++)
{
if (p_cm->cm_reg & topbit)
p_cm->cm_reg = (p_cm->cm_reg << 1) ^ p_cm->cm_poly;
else
p_cm->cm_reg <<= 1;
p_cm->cm_reg &= widmask(p_cm);
}
}
/****************************************************************************/
void cm_blk(
p_cm_t p_cm,
p_ubyte_ blk_adr,
ulong blk_len)
{
while (blk_len--) cm_nxt(p_cm,*blk_adr++);
}
/****************************************************************************/
ulong cm_crc(p_cm_t p_cm)
{
if (p_cm->cm_refot)
return p_cm->cm_xorot ^ reflect(p_cm->cm_reg,p_cm->cm_width);
else
return p_cm->cm_xorot ^ p_cm->cm_reg;
}
/****************************************************************************/
ulong cm_tab(p_cm_t p_cm, int index)
{
int i;
ulong r;
ulong topbit = BITMASK(p_cm->cm_width-1);
ulong inbyte = (ulong) index;
if (p_cm->cm_refin) inbyte = reflect(inbyte,8);
r = inbyte << (p_cm->cm_width-8);
for (i=0; i<8; i++)
if (r & topbit)
r = (r << 1) ^ p_cm->cm_poly;
else
r<<=1;
if (p_cm->cm_refin) r = reflect(r,p_cm->cm_width);
return r & widmask(p_cm);
}
/****************************************************************************/
/* End of crcmodel.c */
/****************************************************************************/

166
pidgen/crcmodel.h Normal file
View File

@ -0,0 +1,166 @@
/****************************************************************************/
/* Start of crcmodel.h */
/****************************************************************************/
/* */
/* Author : Ross Williams (ross@guest.adelaide.edu.au.). */
/* Date : 3 June 1993. */
/* Status : Public domain. */
/* */
/* Description : This is the header (.h) file for the reference */
/* implementation of the Rocksoft^tm Model CRC Algorithm. For more */
/* information on the Rocksoft^tm Model CRC Algorithm, see the document */
/* titled "A Painless Guide to CRC Error Detection Algorithms" by Ross */
/* Williams (ross@guest.adelaide.edu.au.). This document is likely to be in */
/* "ftp.adelaide.edu.au/pub/rocksoft". */
/* */
/* Note: Rocksoft is a trademark of Rocksoft Pty Ltd, Adelaide, Australia. */
/* */
/****************************************************************************/
/* */
/* How to Use This Package */
/* ----------------------- */
/* Step 1: Declare a variable of type cm_t. Declare another variable */
/* (p_cm say) of type p_cm_t and initialize it to point to the first*/
/* variable (e.g. p_cm_t p_cm = &cm_t). */
/* */
/* Step 2: Assign values to the parameter fields of the structure. */
/* If you don't know what to assign, see the document cited earlier.*/
/* For example: */
/* p_cm->cm_width = 16; */
/* p_cm->cm_poly = 0x8005L; */
/* p_cm->cm_init = 0L; */
/* p_cm->cm_refin = TRUE; */
/* p_cm->cm_refot = TRUE; */
/* p_cm->cm_xorot = 0L; */
/* Note: Poly is specified without its top bit (18005 becomes 8005).*/
/* Note: Width is one bit less than the raw poly width. */
/* */
/* Step 3: Initialize the instance with a call cm_ini(p_cm); */
/* */
/* Step 4: Process zero or more message bytes by placing zero or more */
/* successive calls to cm_nxt. Example: cm_nxt(p_cm,ch); */
/* */
/* Step 5: Extract the CRC value at any time by calling crc = cm_crc(p_cm); */
/* If the CRC is a 16-bit value, it will be in the bottom 16 bits. */
/* */
/****************************************************************************/
/* */
/* Design Notes */
/* ------------ */
/* PORTABILITY: This package has been coded very conservatively so that */
/* it will run on as many machines as possible. For example, all external */
/* identifiers have been restricted to 6 characters and all internal ones to*/
/* 8 characters. The prefix cm (for Crc Model) is used as an attempt to */
/* avoid namespace collisions. This package is endian independent. */
/* */
/* EFFICIENCY: This package (and its interface) is not designed for */
/* speed. The purpose of this package is to act as a well-defined reference */
/* model for the specification of CRC algorithms. If you want speed, cook up*/
/* a specific table-driven implementation as described in the document cited*/
/* above. This package is designed for validation only; if you have found or*/
/* implemented a CRC algorithm and wish to describe it as a set of para- */
/* meters to the Rocksoft^tm Model CRC Algorithm, your CRC algorithm imple- */
/* mentation should behave identically to this package under those para- */
/* meters. */
/* */
/****************************************************************************/
/* The following #ifndef encloses this entire */
/* header file, rendering it idempotent. */
#ifndef CM_DONE
#define CM_DONE
#ifdef __cplusplus
extern "C" {
#endif
/****************************************************************************/
/* The following definitions are extracted from my style header file which */
/* would be cumbersome to distribute with this package. The DONE_STYLE is */
/* the idempotence symbol used in my style header file. */
#ifndef DONE_STYLE
typedef unsigned long ulong;
typedef unsigned ubool;
typedef unsigned char * p_ubyte_;
#ifndef TRUE
#define FALSE 0
#define TRUE 1
#endif
/* Uncomment this definition if you don't have void. */
/* typedef int void; */
#endif
/****************************************************************************/
/* CRC Model Abstract Type */
/* ----------------------- */
/* The following type stores the context of an executing instance of the */
/* model algorithm. Most of the fields are model parameters which must be */
/* set before the first initializing call to cm_ini. */
typedef struct
{
int cm_width; /* Parameter: Width in bits [8,32]. */
ulong cm_poly; /* Parameter: The algorithm's polynomial. */
ulong cm_init; /* Parameter: Initial register value. */
ubool cm_refin; /* Parameter: Reflect input bytes? */
ubool cm_refot; /* Parameter: Reflect output CRC? */
ulong cm_xorot; /* Parameter: XOR this to output CRC. */
ulong cm_reg; /* Context: Context during execution. */
} cm_t;
typedef cm_t *p_cm_t;
/****************************************************************************/
/* Functions That Implement The Model */
/* ---------------------------------- */
/* The following functions animate the cm_t abstraction. */
void cm_ini(p_cm_t p_cm);
/* Initializes the argument CRC model instance. */
/* All parameter fields must be set before calling this. */
void cm_nxt(p_cm_t p_cm, int ch);
/* Processes a single message byte [0,255]. */
void cm_blk(p_cm_t p_cm, p_ubyte_ blk_adr, ulong blk_len);
/* Processes a block of message bytes. */
ulong cm_crc(p_cm_t p_cm);
/* Returns the CRC value for the message bytes processed so far. */
/****************************************************************************/
/* Functions For Table Calculation */
/* ------------------------------- */
/* The following function can be used to calculate a CRC lookup table. */
/* It can also be used at run-time to create or check static tables. */
ulong cm_tab(p_cm_t p_cm, int index);
/* Returns the i'th entry for the lookup table for the specified algorithm. */
/* The function examines the fields cm_width, cm_poly, cm_refin, and the */
/* argument table index in the range [0,255] and returns the table entry in */
/* the bottom cm_width bytes of the return value. */
/****************************************************************************/
/* End of the header file idempotence #ifndef */
#ifdef __cplusplus
}
#endif
#endif
/****************************************************************************/
/* End of crcmodel.h */
/****************************************************************************/

108
pidgen/crtstubs.cpp Normal file
View File

@ -0,0 +1,108 @@
/*++
Copyright (c) 1998-1999, Microsoft Corporation
Module Name:
CRTStubs.cpp
Abstract:
--*/
#include <windows.h>
#include <stdlib.h>
#if 0
//=--------------------------------------------------------------------------=
// CRT stubs
//=--------------------------------------------------------------------------=
// these two things are here so the CRTs aren't needed. this is good.
//
// basically, the CRTs define this to get in a bunch of stuff. we'll just
// define them here so we don't get an unresolved external.
//
// TODO: if you are going to use the CRTs, then remove this line.
//
extern "C" int _fltused = 1;
extern "C" int _cdecl _purecall(void)
{
// FAIL("Pure virtual function called.");
return 0;
}
void * _cdecl operator new
(
size_t size
)
{
return HeapAlloc(GetProcessHeap(), 0, size);
}
//=---------------------------------------------------------------------------=
// overloaded delete
//=---------------------------------------------------------------------------=
// retail case just uses win32 Local* heap mgmt functions
//
// Parameters:
// void * - [in] free me!
//
// Notes:
//
void _cdecl operator delete ( void *ptr)
{
HeapFree(GetProcessHeap(), 0, ptr);
}
#ifndef _X86_
extern "C" void _fpmath() {}
#endif
#ifndef _DEBUG
void * _cdecl malloc(size_t n)
{
#ifdef _MALLOC_ZEROINIT
void* p = HeapAlloc(g_hHeap, 0, n);
if (p != NULL)
ZeroMemory(p, n);
return p;
#else
return HeapAlloc(GetProcessHeap(), 0, n);
#endif
}
void * _cdecl calloc(size_t n, size_t s)
{
#ifdef _MALLOC_ZEROINIT
return malloc(n * s);
#else
void* p = malloc(n * s);
if (p != NULL)
ZeroMemory(p, n * s);
return p;
#endif
}
void* _cdecl realloc(void* p, size_t n)
{
if (p == NULL)
return malloc(n);
return HeapReAlloc(GetProcessHeap(), 0, p, n);
}
void _cdecl free(void* p)
{
if (p == NULL)
return;
HeapFree(GetProcessHeap(), 0, p);
}
#endif
#endif

30
pidgen/ddk/sources Normal file
View File

@ -0,0 +1,30 @@
!IF 0
Copyright (c) 1989 Microsoft Corporation
Module Name:
sources.
Abstract:
This file specifies the target component being built and the list of
sources files needed to build that component. Also specifies optional
compiler switches and libraries that are unique for the component being
built.
!ENDIF
!include ..\sources.inc
C_DEFINES=$(C_DEFINES) -DBUILD_DDK
BINPLACE_FLAGS=-b dump
TARGETNAME=pidgen
TARGETPATH=..\..\lib\ddk\$(_OBJ_DIR)
TARGETTYPE=DYNLINK
DLLDEF=..\pidgen.def
LINKER_FLAGS=/SWAPRUN:CD /SWAPRUN:NET

12
pidgen/dirs Normal file
View File

@ -0,0 +1,12 @@
!IF 0
This file is used by build.exe to determine which directories
in which to build. They are entered in order listed.
!ENDIF
DIRS=wks srv per ddk trial vol eval

30
pidgen/dll/sources Normal file
View File

@ -0,0 +1,30 @@
!IF 0
Copyright (c) 1989 Microsoft Corporation
Module Name:
sources.
Abstract:
This file specifies the target component being built and the list of
sources files needed to build that component. Also specifies optional
compiler switches and libraries that are unique for the component being
built.
Author:
Andrew Ritz (andrewr)
!ENDIF
!include ..\sources.inc
TARGETNAME=pidgen
TARGETPATH=..\..\lib
TARGETTYPE=DYNLINK
DLLDEF=..\pidgen.def
LINKER_FLAGS=/SWAPRUN:CD /SWAPRUN:NET

28
pidgen/eval/sources Normal file
View File

@ -0,0 +1,28 @@
!IF 0
Copyright (c) 1989 Microsoft Corporation
Module Name:
sources.
Abstract:
This file specifies the target component being built and the list of
sources files needed to build that component. Also specifies optional
compiler switches and libraries that are unique for the component being
built.
!ENDIF
!include ..\sources.inc
C_DEFINES=$(C_DEFINES) -DBUILD_EVAL
TARGETNAME=epidgen
TARGETPATH=..\..\lib\trial\$(_OBJ_DIR)
TARGETTYPE=DYNLINK
DLLDEF=..\pidgen.def
LINKER_FLAGS=/SWAPRUN:CD /SWAPRUN:NET

690
pidgen/hardware.cpp Normal file
View File

@ -0,0 +1,690 @@
/*++
Copyright (c) 1998-1999, Microsoft Corporation
Module Name:
Hardware.h
Abstract:
--*/
#include "Hardware.h"
#include <stdio.h> // only needed for testing
#if defined(WIN32) || defined(_WIN32)
static inline BOOL IsPlatformNT()
{
// always do it 'The NT Way'
return TRUE;
/*/////////////////////////////////////////////////////////////////////////////
OSVERSIONINFO osvInfo;
BOOL fNTPlatformFlag;
osvInfo.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
GetVersionEx( &osvInfo );
switch( osvInfo.dwPlatformId )
{
case VER_PLATFORM_WIN32_NT:
fNTPlatformFlag = TRUE;
break;
default:
fNTPlatformFlag = FALSE;
break;
}
return( fNTPlatformFlag );
*//////////////////////////////////////////////////////////////////////////////
}
#else
inline BOOL IsPlatformNT()
{
return FALSE;
}
extern "C" extern WORD _C000H;
extern "C" extern WORD _F000H;
#endif
CHardware::CHardware()
#ifdef HWID_DETAIL ////////////////////////////////////////////////////////////
: m_dwBiosCrc32(0),
m_dwVolSer(0),
m_dwTotalRamMegs(0),
m_dwVideoBiosCrc32(0)
#endif
{
uClassID = CHARDWARE_CLASSID;
ZeroMemory( (LPVOID)m_szHardwareID, HARDWARE_ID_SIZE );
SetBIOSDigit();
SetHDSerialDigit();
SetTotalRAMDigit();
SetFDConfigDigit();
SetVideoBIOSDigit();
#ifndef NO_HWID_GUID //////////////////////////////////////////////////////////
CalculateHardwareGUID();
#endif ////////////////////////////////////////////////////////////////////////
}
CHardware::~CHardware()
{
}
DWORD CHardware::GetType()
{
return(IsPlatformNT() ? 1 : 0);
}
LPSTR CHardware::GetID()
{
return( m_szHardwareID );
}
#ifndef NO_HWID_GUID //////////////////////////////////////////////////////////
LPSTR CHardware::GetGUID()
{
return( m_szHardwareGUID );
}
#endif ////////////////////////////////////////////////////////////////////////
VOID CHardware::SetBIOSDigit()
{
DWORD dwBIOSChecksum;
#if defined(WIN32) || defined(_WIN32)
if ( IsPlatformNT() )
{
dwBIOSChecksum = CalculateRegKeyChecksum( "SystemBiosDate" );
dwBIOSChecksum += CalculateRegKeyChecksum( "SystemBiosVersion" );
m_dwBiosCrc32 = dwBIOSChecksum;
} else
#endif
{
LPBYTE pbMemoryByte;
#if defined(WIN32) || defined(_WIN32)
pbMemoryByte = (LPBYTE)0xF0000;
#else
pbMemoryByte = (LPBYTE)MAKELONG(0, &_F000H);
#endif
dwBIOSChecksum = CalculateMemoryRegionChecksum(pbMemoryByte, 2048);
#ifdef HWID_DETAIL ////////////////////////////////////////////////////////////
m_dwBiosCrc32 = CRC_32(pbMemoryByte, 2048);
#endif
}
m_szHardwareID[ BIOS_DIGIT ] = (CHAR)( dwBIOSChecksum % 9 ) + '0';
}
#if defined(WIN32) || defined(_WIN32)
UINT CHardware::CalculateRegKeyChecksum(LPSTR lpszKey)
{
LONG lStatus;
HKEY hkSystem;
UINT uChecksum;
uChecksum = 0;
lStatus = RegOpenKeyEx( HKEY_LOCAL_MACHINE, TEXT("HARDWARE\\DESCRIPTION\\System"), 0, KEY_QUERY_VALUE, &hkSystem );
_ASSERT( lStatus == ERROR_SUCCESS );
if ( lStatus == ERROR_SUCCESS )
{
DWORD dwValueType;
DWORD dwBufferSize;
BYTE Buffer[ MAX_BIOS_KEY_LENGTH ];
dwBufferSize = MAX_BIOS_KEY_LENGTH;
lStatus = RegQueryValueExA( hkSystem, lpszKey, NULL, &dwValueType, Buffer, &dwBufferSize );
// ASSERT( lStatus == ERROR_SUCCESS ); // Not all values are guarenteed to exist
if ( lStatus == ERROR_SUCCESS )
{
UINT nCurrentByte;
for ( nCurrentByte = 0; nCurrentByte < dwBufferSize; nCurrentByte++ )
{
uChecksum += Buffer[ nCurrentByte ];
}
}
RegCloseKey( hkSystem );
}
return( uChecksum );
}
#endif
DWORD CHardware::CalculateMemoryRegionChecksum( LPBYTE pbChecksumArea, INT nNumberBytes )
{
DWORD dwRegionChecksum = 0;
while (0 < nNumberBytes)
{
dwRegionChecksum += (UINT)( *pbChecksumArea );
++pbChecksumArea;
--nNumberBytes;
}
return( dwRegionChecksum );
}
#if !defined(WIN32) && !defined(_WIN32)
#pragma pack(1)
// Media ID
typedef struct {
WORD wInfoLevel;
DWORD dwSerialNum;
char achVolLabel[11];
BYTE abFileSysType[8];
} MID, *PMID, FAR* LPMID;
#pragma pack()
#endif
VOID CHardware::SetHDSerialDigit()
{
m_szHardwareID[ HD_SERIAL_DIGIT ] = '?';
BOOL fInfoSuccess;
DWORD dwVolumeSerialNumber;
#if defined(WIN32) || defined(_WIN32)
DWORD dwFileSystemFlags;
DWORD dwMaximumComponentLength;
CHAR szBootDrivePath[ MAX_PATH ];
wsprintfA( szBootDrivePath, "C:\\" );
fInfoSuccess = GetVolumeInformationA( szBootDrivePath, NULL, 0, &dwVolumeSerialNumber, &dwMaximumComponentLength, &dwFileSystemFlags, NULL, 0 );
_ASSERT( fInfoSuccess );
#else
LPMID pmid;
union _REGS regs;
struct _SREGS segregs;
DWORD dwMem;
dwMem = GlobalDosAlloc(sizeof(MID));
WORD wMidSelector = LOWORD(dwMem);
WORD wMidSegment = HIWORD(dwMem);
pmid = (LPMID)MAKELP(wMidSelector, 0);
ZeroMemory(pmid, sizeof(MID));
ZeroMemory(&regs, sizeof(regs));
ZeroMemory(&segregs, sizeof(segregs));
regs.x.ax = 0x440d; // DOS Function 440Dh - IOCTL for Block Device
regs.h.cl = 0x66; // Minor Code 66h - Get Media ID
regs.h.ch = 0x08; // Device category (must be 08h)
regs.x.bx = 3; // Drive C:
regs.x.dx = 0; // pmid offset
segregs.ds = wMidSelector; // wMidSegment;
segregs.es = wMidSelector; // wMidSegment;
_intdosx(&regs, &regs, &segregs);
fInfoSuccess = !regs.x.cflag;
dwVolumeSerialNumber = pmid->dwSerialNum;
GlobalDosFree(wMidSelector);
#endif
if ( fInfoSuccess )
{
m_szHardwareID[ HD_SERIAL_DIGIT ] = (CHAR)( dwVolumeSerialNumber % 9 ) + '0';
#ifdef HWID_DETAIL ////////////////////////////////////////////////////////////
m_dwVolSer = dwVolumeSerialNumber;
#endif
}
}
VOID CHardware::SetTotalRAMDigit()
{
DWORD dwTotalMegabytes;
m_szHardwareID[ TOTAL_RAM_DIGIT ] = '?';
#if defined(WIN32) || defined(_WIN32)
MEMORYSTATUS mStatus;
mStatus.dwLength = sizeof( MEMORYSTATUS );
GlobalMemoryStatus( &mStatus );
dwTotalMegabytes = (DWORD)( mStatus.dwTotalPhys / (1024 * 1024)); // convert to megabytes
dwTotalMegabytes += 1; // Add 1Mb to produce accurate result due to reserved space
#else
BYTE abDpmiMemInfo[0x30];
FillMemory(abDpmiMemInfo, sizeof(abDpmiMemInfo), -1);
__asm {
push di ;save regs
push ss
pop es ;make es point to stack
lea di,abDpmiMemInfo ;Get offset of buffer
mov ax,0500h ;DPMI -- Get Free Memory Info
int 31h ;Call DPMI
pop di ;restore regs
}
DWORD dwTotalPages = *(LPDWORD)&abDpmiMemInfo[0x18];
// check to see if the field is -1 (error) and just use 0
// we're adding 1 to account for the memory below 1M (I think)
dwTotalMegabytes = (dwTotalPages == -1) ? 0 : (1 + dwTotalPages/(1024/4));
#endif
m_szHardwareID[ TOTAL_RAM_DIGIT ] = (CHAR)( dwTotalMegabytes % 9 ) + '0';
#ifdef HWID_DETAIL ////////////////////////////////////////////////////////////
m_dwTotalRamMegs = dwTotalMegabytes;
#endif
}
VOID CHardware::SetFDConfigDigit()
{
DWORD dwFDConfig;
#if defined(WIN32) || defined(_WIN32)
if ( IsPlatformNT() )
{
dwFDConfig = CalculateDriveCapacityNT( 1 ) << 2;
dwFDConfig += CalculateDriveCapacityNT( 2 );
} else
#endif
{
#ifndef _WIN64
dwFDConfig = CalculateDriveCapacity95( 1 ) << 2;
dwFDConfig += CalculateDriveCapacity95( 2 );
#endif
}
m_szHardwareID[ FD_CONFIG_DIGIT ] = (CHAR)( dwFDConfig % 9 ) + '0';
}
#ifndef _WIN64
DWORD CHardware::CalculateDriveCapacity95( INT nDrive )
{
DWORD dwDriveCapacity = 0;
BOOL fOk;
UINT uNumberHeads;
UINT uNumberTracks;
UINT uBytesPerSector;
UINT uSectorsPerTrack;
LPBYTE pbDiskParamTable;
#if defined(WIN32) || defined(_WIN32)
HANDLE hDevice;
BOOL fResult;
DIOC_REGISTERS DIOCRegs;
DWORD dwBytesReturned;
// Open VWIN32 Device For Access To DOS Int 13h Functions
hDevice = CreateFile( TEXT("\\\\.\\vwin32"), 0, 0, NULL, 0, FILE_FLAG_DELETE_ON_CLOSE, NULL );
fOk = (hDevice != INVALID_HANDLE_VALUE);
if (fOk)
{
// Invoke Int 13h Function 08h - Get Drive Parameters
DIOCRegs.reg_EAX = 0x0800; // Get Drive Parameters
DIOCRegs.reg_EDX = nDrive - 1; // 0 = A:, 1 = B:
fResult = DeviceIoControl( hDevice, VWIN32_DIOC_DOS_INT13, &DIOCRegs, sizeof( DIOC_REGISTERS ), &DIOCRegs, sizeof( DIOC_REGISTERS ), &dwBytesReturned, NULL );
// Determine if Int 13h Call Succeeded
fOk = (fResult == TRUE && 0 == (DIOCRegs.reg_Flags & FLAGS_CARRY));
}
if (fOk)
{
// Calculate Drive Capacity if Drive Number is Valid
if ( ( DIOCRegs.reg_EDX & 0xFF ) >= (UINT)nDrive )
{
pbDiskParamTable = (UCHAR *)DIOCRegs.reg_EDI;
uNumberHeads = ( ( DIOCRegs.reg_EDX >> 8 ) & 0xFF ) + 1;
uNumberTracks = ( ( ( DIOCRegs.reg_ECX << 2 ) & 0x300 ) + ( ( DIOCRegs.reg_ECX >> 8 ) & 0xFF ) ) + 1;
uSectorsPerTrack = ( DIOCRegs.reg_ECX & 0x3F );
uBytesPerSector = ( 128 << ( *( pbDiskParamTable + 3 ) ) );
dwDriveCapacity = uNumberHeads * uNumberTracks * uSectorsPerTrack * uBytesPerSector;
}
}
if (hDevice != INVALID_HANDLE_VALUE)
{
CloseHandle( hDevice );
}
#else
union _REGS regs;
struct _SREGS segregs;
ZeroMemory(&regs, sizeof(regs));
ZeroMemory(&segregs, sizeof(segregs));
regs.h.ah = 0x08; // BIOS Function 08h - Get drive parameters
regs.x.dx = nDrive - 1; // 0 = A:, 1 = B:
_int86x(
0x13, // BIOS Disk
&regs,
&regs,
&segregs);
fOk = (!regs.x.cflag);
if (fOk)
{
uNumberHeads = regs.h.dh + 1;
uNumberTracks = ((regs.h.cl & 0xC0) << 2) + regs.h.ch + 1;
uSectorsPerTrack = regs.h.cl & 0x3F;
pbDiskParamTable = (LPBYTE)MAKELP(segregs.es, regs.x.di);
uBytesPerSector = (128 << pbDiskParamTable[3]);
dwDriveCapacity = (DWORD)uNumberHeads * uNumberTracks * uSectorsPerTrack * uBytesPerSector;
}
#endif
dwDriveCapacity /= ( 1024L * 100L );
return( dwDriveCapacity );
}
#endif
#if defined(WIN32) || defined(_WIN32)
DWORD CHardware::CalculateDriveCapacityNT(INT nDrive)
{
BOOL fDriveExists;
DWORD dwDriveCapacity;
DWORD dwBytesReturned;
TCHAR szDrive[ MAX_PATH ];
TCHAR szDriveAssignment[ MAX_PATH ];
dwDriveCapacity = 0;
// Determine if Logical Drive Exists
fDriveExists = FALSE;
wsprintf( szDrive, TEXT("%c:"), TEXT('A') + ( nDrive - 1 ) ); // Create DOS Drive Identifier (A: or B:)
dwBytesReturned = QueryDosDevice( szDrive, szDriveAssignment, MAX_PATH );
if ( dwBytesReturned != 0 )
{
LPTSTR lpszWalkString;
// DBCS-Enabled Terminate String At 2nd Backslash (1st Backslash always at Position 0)
lpszWalkString = szDriveAssignment;
do
{
lpszWalkString = CharNext( lpszWalkString );
switch( *lpszWalkString )
{
case '\\':
*lpszWalkString = 0;
break;
}
}
while( *lpszWalkString != 0 );
// Determine if Logical Drive is Physically Present
if ( lstrcmp( szDriveAssignment, TEXT("\\Device") ) == 0 )
{
fDriveExists = TRUE;
}
}
if ( fDriveExists == TRUE )
{
// Get All Supported Media Types for Drive
HANDLE hDevice;
BOOL fResult;
wsprintf( szDrive, TEXT("\\\\.\\%c:"), TEXT('A') + ( nDrive - 1 ) ); // Create NT Drive Identifier (\\.\A: or \\.\B:)
hDevice = CreateFile( szDrive, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL );
_ASSERT( hDevice != INVALID_HANDLE_VALUE );
if ( hDevice != INVALID_HANDLE_VALUE )
{
DISK_GEOMETRY dGeometry[ 10 ];
fResult = DeviceIoControl( hDevice, IOCTL_DISK_GET_MEDIA_TYPES, NULL, 0, (LPVOID)&dGeometry, sizeof( DISK_GEOMETRY ) * 10, &dwBytesReturned, NULL );
_ASSERT( fResult );
if ( fResult == TRUE )
{
// Calculate Maximum Media Size of Drive in Bytes if No Errors
INT nMediaCount;
INT nCurrentMedia;
UINT uCurrentMediaCapacity;
nMediaCount = dwBytesReturned / sizeof( DISK_GEOMETRY );
for ( nCurrentMedia = 0; nCurrentMedia < nMediaCount; nCurrentMedia++ )
{
uCurrentMediaCapacity = (UINT)dGeometry[ nCurrentMedia ].Cylinders.LowPart;
uCurrentMediaCapacity *= (UINT)dGeometry[ nCurrentMedia ].TracksPerCylinder;
uCurrentMediaCapacity *= (UINT)dGeometry[ nCurrentMedia ].SectorsPerTrack;
uCurrentMediaCapacity *= (UINT)dGeometry[ nCurrentMedia ].BytesPerSector;
if ( uCurrentMediaCapacity > dwDriveCapacity )
{
dwDriveCapacity = uCurrentMediaCapacity;
}
}
}
CloseHandle( hDevice );
}
}
dwDriveCapacity /= ( 1024 * 100 );
return( dwDriveCapacity );
}
#endif
VOID CHardware::SetVideoBIOSDigit()
{
DWORD dwVideoBIOSChecksum;
#if defined(WIN32) || defined(_WIN32)
if ( IsPlatformNT() )
{
dwVideoBIOSChecksum = CalculateRegKeyChecksum( "VideoBiosDate" );
dwVideoBIOSChecksum += CalculateRegKeyChecksum( "VideoBiosVersion" );
#ifdef HWID_DETAIL ////////////////////////////////////////////////////////////
m_dwVideoBiosCrc32 = dwVideoBIOSChecksum;
#endif
} else
#endif
{
LPBYTE pbMemoryByte;
#if defined(WIN32) || defined(_WIN32)
pbMemoryByte = (LPBYTE)0xC0000;
#else
pbMemoryByte = (LPBYTE)MAKELONG(0, &_C000H);
#endif
dwVideoBIOSChecksum = CalculateMemoryRegionChecksum(pbMemoryByte, 2048);
#ifdef HWID_DETAIL ////////////////////////////////////////////////////////////
m_dwVideoBiosCrc32 = CRC_32(pbMemoryByte, 2048);
#endif
}
m_szHardwareID[ VIDEO_BIOS_DIGIT ] = (CHAR)( dwVideoBIOSChecksum % 9 ) + '0';
}
#ifndef NO_HWID_GUID //////////////////////////////////////////////////////////
VOID CHardware::CalculateHardwareGUID()
{
ULONG uCRC;
INT nIndex;
CHAR szCRCTemp[ 20 ];
// Create Empty Template for GUID
lstrcpyA( m_szHardwareGUID, "{30303030-30DA-0000-0000-0020AFC36E79}" );
// Add ASCII HWID to GUID
for ( nIndex = 0; nIndex < lstrlenA( m_szHardwareID ); nIndex++ )
{
switch( nIndex )
{
case 0:
case 1:
case 2:
case 3:
m_szHardwareGUID[ 2 + ( nIndex * 2 ) ] = m_szHardwareID[ nIndex ];
break;
case 4:
m_szHardwareGUID[ 11 ] = m_szHardwareID[ nIndex ];
break;
default:
_ASSERT( FALSE );
break;
}
}
// Calculate GUID CRC
CCrc32 crc32;
_ASSERT( crc32.uClassID == CCRC32_CLASSID );
uCRC = crc32.CalculateBlockCRC( m_szHardwareGUID, lstrlenA( m_szHardwareGUID ) );
// Add CRC Result To GUID
wsprintf( szCRCTemp, "%08X", uCRC );
for ( nIndex = 0; nIndex < lstrlenA( szCRCTemp ); nIndex++ )
{
switch( nIndex )
{
case 0:
case 1:
case 2:
case 3:
m_szHardwareGUID[ 15 + nIndex ] = szCRCTemp[ nIndex ];
break;
case 4:
case 5:
case 6:
case 7:
m_szHardwareGUID[ 16 + nIndex ] = szCRCTemp[ nIndex ];
break;
default:
_ASSERT( FALSE );
break;
}
}
}
#endif ////////////////////////////////////////////////////////////////////////
#if 0 /////////////////////////////////////////////////////////////////////////
// Test main() function
int PASCAL WinMain(
HINSTANCE, // hInstance, // handle to current instance
HINSTANCE, // hPrevInstance, // handle to previous instance
LPSTR, // lpCmdLine, // pointer to command line
int // nCmdShow // show state of window)
)
{
CHardware hwid;
MessageBox(
NULL,
(char *)hwid.GetGUID(),
(char *)hwid.GetID(),
MB_OK);
return 0;
}
#endif ////////////////////////////////////////////////////////////////////////

60
pidgen/hardware.h Normal file
View File

@ -0,0 +1,60 @@
/*++
Copyright (c) 1998-1999, Microsoft Corporation
Module Name:
Hardware.h
Abstract:
--*/
#ifndef HARDWARE_H
#define HARDWARE_H
#define NO_HWID_GUID
#define HWID_DETAIL
#include <string.h> // needed by compobj.h
#include <windows.h>
#if defined(WIN32) || defined(_WIN32)
#include <crtdbg.h>
#else
typedef short INT;
typedef char CHAR;
#include <toolhelp.h>
#include <assert.h>
#define _ASSERT assert
#include <compobj.h> // needed for 16-bit build
#include <dos.h>
#endif
#include <string.h>
#include "tchar.h"
#if defined(WIN32) || defined(_WIN32)
#include <winioctl.h>
#endif
// #include "LicWiz.h"
#include "CHardwar.h"
#ifndef NO_HWID_GUID //////////////////////////////////////////////////////////
#include "crc32.h"
#endif
#include "crc-32.h"
#endif

26
pidgen/lib/sources Normal file
View File

@ -0,0 +1,26 @@
!IF 0
Copyright (c) 1989 Microsoft Corporation
Module Name:
sources.
Abstract:
This file specifies the target component being built and the list of
sources files needed to build that component. Also specifies optional
compiler switches and libraries that are unique for the component being
built.
Author:
Andrew Ritz (andrewr)
!ENDIF
!include ..\sources.inc
TARGETNAME=pidgen
TARGETPATH=..\..\lib
TARGETTYPE=LIBRARY

79
pidgen/main.cpp Normal file
View File

@ -0,0 +1,79 @@
/*++
Copyright (c) 1998-1999, Microsoft Corporation
Module Name:
main.cpp
Abstract:
--*/
#include <windows.h>
#include "pidgen.h"
#if !defined(WIN32) && !defined(_WIN32)
#include <string.h>
#endif // !defined(WIN32) && !defined(_WIN32)
#if TESTING_CODE
#include <stdio.h>
#endif
HINSTANCE g_hinst = NULL;
#if defined(WIN32) || defined(_WIN32)
//int main()
//{
//
// return(0);
//}
BOOL WINAPI DllMain(
HANDLE hinst,
ULONG ulReason,
LPVOID lpReserved)
{
if (DLL_PROCESS_ATTACH == ulReason)
{
g_hinst = (HINSTANCE)hinst;
}
return TRUE;
}
#else
extern "C" int STDAPICALLTYPE LibMain(
HINSTANCE hinst,
WORD wDataSeg,
WORD cbHeapSize,
LPSTR lpszCmdLine)
{
// Perform DLL initialization.
g_hinst = hinst;
if (cbHeapSize != 0) // DLL data seg is MOVEABLE
{
UnlockData(0);
}
return 1; // return success
}
extern "C" int STDAPICALLTYPE WEP(int nParameter)
{
return 1;
}
#endif

35
pidgen/per/sources Normal file
View File

@ -0,0 +1,35 @@
!IF 0
Copyright (c) 1989 Microsoft Corporation
Module Name:
sources.
Abstract:
This file specifies the target component being built and the list of
sources files needed to build that component. Also specifies optional
compiler switches and libraries that are unique for the component being
built.
!ENDIF
!include ..\sources.inc
!if $(BETA_PID)
C_DEFINES=$(C_DEFINES) -DBUILD_TRIAL
!else
C_DEFINES=$(C_DEFINES) -DBUILD_PER
!endif
BINPLACE_FLAGS=-o perinf
TARGETNAME=pidgen
TARGETPATH=..\..\lib\per\$(_OBJ_DIR)
TARGETTYPE=DYNLINK
DLLDEF=..\pidgen.def
LINKER_FLAGS=/SWAPRUN:CD /SWAPRUN:NET

1188
pidgen/pidgen.cpp Normal file

File diff suppressed because it is too large Load Diff

13
pidgen/pidgen.def Normal file
View File

@ -0,0 +1,13 @@
; PIDGen.def
LIBRARY PIDGen.dll
EXPORTS
PIDGenA @1
PIDGenW @2
PIDGenSimpA @3
PIDGenSimpW @4
SetupPIDGenA @5
SetupPIDGenW @6
VerifyPIDSequenceW @7

46
pidgen/pidgen.rc Normal file
View File

@ -0,0 +1,46 @@
#include <windows.h>
#include <ntverp.h>
#ifdef BUILD_SRV
1 BINK DISCARDABLE "00010.pub"
2 BINK DISCARDABLE "00019.pub"
#endif
#ifdef BUILD_DDK
1 BINK DISCARDABLE "00008.pub"
2 BINK DISCARDABLE "00009.pub"
#endif
#ifdef BUILD_PRO
1 BINK DISCARDABLE "00044.pub"
2 BINK DISCARDABLE "00045.pub"
#endif
#ifdef BUILD_PER
1 BINK DISCARDABLE "00042.pub"
2 BINK DISCARDABLE "00043.pub"
#endif
#ifdef BUILD_TRIAL
1 BINK DISCARDABLE "00000.pub"
2 BINK DISCARDABLE "00001.pub"
#endif
#ifdef BUILD_VOL
1 BINK DISCARDABLE "00046.pub"
2 BINK DISCARDABLE "00047.pub"
#endif
#ifdef BUILD_EVAL
1 BINK DISCARDABLE "00040.pub"
2 BINK DISCARDABLE "00041.pub"
#endif
#define VER_FILETYPE VFT_APP
#define VER_FILESUBTYPE VFT2_UNKNOWN
#define VER_FILEDESCRIPTION_STR "Pid3.0 generation"
#define VER_INTERNALNAME_STR "pidgen.dll"
#define VER_ORIGINALFILENAME_STR "pidgen.dll"
#include "common.ver"

244
pidgen/range.cpp Normal file
View File

@ -0,0 +1,244 @@
/*++
Copyright (c) 1998-2002, Microsoft Corporation
Module Name:
range.cpp
Abstract:
--*/
#include <windows.h>
#include "pidgen.h"
#include "range.h"
#include "rangedat.h"
LONG
GetSkuName(
OUT PWCHAR pszSKU,
IN DWORD cBytes
)
/*++
Routine Description:
This routine will read the registry for the PRO variation name, the SKU.
Arguments:
szSKU - buffer to hold the string to the SKU.
cBytes - number of bytes buffer can hold.
Return Value:
ERROR_SUCCESS for success.
Error code for failure.
--*/
{
LONG lRet;
HKEY hKeySKU = NULL;
DWORD dwType;
lRet = RegOpenKeyW( HKEY_LOCAL_MACHINE, szSKULocationKey, &hKeySKU);
if (lRet != ERROR_SUCCESS) {
goto done;
}
lRet = RegQueryValueExW( hKeySKU, szSKULocationValue, NULL, &dwType, (LPBYTE)pszSKU, &cBytes);
pszSKU[cBytes/sizeof(WCHAR)-1] = L'\0';
if( lRet != ERROR_SUCCESS) {
goto done;
}
// Must be string type and not empty.
if( dwType != REG_SZ || !pszSKU[0]) {
lRet = ERROR_INVALID_DATA;
goto done;
}
done:
if( hKeySKU) {
RegCloseKey( hKeySKU);
}
return lRet;
}
PSEQUENCE_RANGE
GetRange(
IN BOOL fOem,
IN PCWSTR pszSKU
)
/*++
Routine Description:
This routine will return the inclusion range table for the
given SKU string.
Arguments:
fOem - oem or retail
pszSKU - string to the SKU.
Return Value:
PSEQUENCE_RANGE - pointer to the inclusion sequence table.
--*/
{
DWORD dwRangeCount = sizeof(rangeTable)/sizeof(rangeTable[0]);
while( dwRangeCount) {
dwRangeCount--;
if( wcscmp( pszSKU, rangeTable[dwRangeCount].pszSKU) == 0) {
if( fOem) {
return( rangeTable[dwRangeCount].psrOem);
} else {
return( rangeTable[dwRangeCount].psrRetail);
}
}
}
return NULL;
}
BOOL
IsSequenceIncluded(
IN DWORD dwSeq,
IN PSEQUENCE_RANGE pseqRange
)
/*++
Routine Description:
This routine will determine if a sequnce number is within the SKU range.
Arguments:
dwSeq - sequence to check
pseqRange - the range
Return Value:
BOOL - TRUE if in range, FALSE if not in range.
--*/
{
// We must have a valid range passed in otherwise return false.
if( !pseqRange) {
return FALSE;
}
// We assume at least one valid range sequence pointed to by pseqRange -not just the empty range which
// indicates the end of the table.
while( (pseqRange->dwStartSeq != 0) && (pseqRange->dwEndSeq != 0)) {
if (dwSeq >= pseqRange->dwStartSeq && dwSeq <= pseqRange->dwEndSeq) {
return TRUE;
}
pseqRange++;
}
return FALSE;
}
BOOL CheckSkuRange(
IN BOOL fOem,
IN DWORD dwSeq
)
/*++
Routine Description:
This routine will determine if a sequence is valid for the current professional SKU.
The SKU is read from the registry to determine the valid range. The valid range
per sku is kept in tables in pidgen.
Arguments:
fOem - oem or retail
dwSeq - Sequence to check.
Return Value:
BOOL, TRUE if sequence is valid, FALSE if sequence is invalid.
--*/
{
DWORD dwRangeCount = sizeof(rangeTable)/sizeof(rangeTable[0]);
WCHAR szSKURead[MAX_PATH];
PSEQUENCE_RANGE pseqRange;
LONG lRet;
// Get the name of the sku from the registry.
lRet = GetSkuName( szSKURead, sizeof(szSKURead) );
// If we don't find an inclusion range in the registry then
// assume all ranges are accepted (in other words plain vanilla pro).
if( lRet != ERROR_SUCCESS) {
return( TRUE);
}
// Get the inclusion range for this sku.
pseqRange = GetRange( fOem, szSKURead);
// If we don't find a range table then assume a new sku (variation of pro) was created
// which we don't understand so deny cross upgrade.
if( !pseqRange) {
return (FALSE);
}
// If the product id fits in this range return true.
return( IsSequenceIncluded( dwSeq, pseqRange));
}
extern "C" DWORD STDAPICALLTYPE VerifyPIDSequenceW(
IN BOOL fOem,
IN DWORD dwSeq,
IN PCWSTR pszSKU
)
/*++
Routine Description:
This routine will determine if a sequence is valid for a particular sku.
Arguments:
fOem - oem or retail
dwSeq - Sequence to check.
pszSKU - null terminated string for the SKU.
Return Value:
pgeSuccess if sequence is in range.
pgeProductKeyExcluded if sequence is not in range.
pgeProductKeyInvalid if range table not found.
--*/
{
PSEQUENCE_RANGE pseqRange;
// Get the inclusion range for this sku.
pseqRange = GetRange( fOem, pszSKU);
// If we don't find a range table then assume a new sku (variation of pro) was created
// which we don't understand.
if( !pseqRange) {
return (pgeProductKeyInvalid);
}
// If the product id fits in this range return true.
if ( IsSequenceIncluded( dwSeq, pseqRange)) {
return (pgeSuccess);
} else {
return (pgeProductKeyExcluded);
}
}

43
pidgen/range.h Normal file
View File

@ -0,0 +1,43 @@
/*++
Copyright (c) 1998-2002, Microsoft Corporation
Module Name:
range.h
Abstract:
--*/
#ifndef _RANGE_H_
#define _RANGE_H_
/*
Structure to hold ChID and Sequence Number.
*/
typedef struct _SEQUENCE_RANGE {
DWORD dwStartSeq;
DWORD dwEndSeq;
} SEQUENCE_RANGE, *PSEQUENCE_RANGE;
/*
Structure to hold range for each sku
*/
typedef struct _SKU_RANGE {
PCWSTR pszSKU;
PSEQUENCE_RANGE psrRetail;
PSEQUENCE_RANGE psrOem;
} SKU_RANGE, *PSKU_RANGE;
static const WCHAR szSKULocationKey[] = L"System\\WPA\\PIDRange";
static const WCHAR szSKULocationValue[] = L"SKURange";
BOOL CheckSkuRange(
IN BOOL fOem,
IN DWORD dwSeq
);
#endif

143
pidgen/rangedat.h Normal file
View File

@ -0,0 +1,143 @@
/*++
Copyright (c) 1998-2002, Microsoft Corporation
Module Name:
rangedat.h
Abstract:
--*/
#ifndef _RANGEDATA_H_
#define _RANGEDATA_H_
static const WCHAR szTablet[] = L"TabletPC";
#if defined BUILD_PRO
#ifdef WINXP_SPx_RTM
static SEQUENCE_RANGE srTabletRetail[] = {
{ 360000000, 364999999},
{ 0, 0}
};
static SEQUENCE_RANGE srTabletOem[] = {
{ 170000000, 269999999},
{ 119000300, 119000799},
{ 0, 0}
};
#else
static SEQUENCE_RANGE srTabletRetail[] = {
{ 2400000, 2449999},
{ 0, 0}
};
static SEQUENCE_RANGE srTabletOem[] = {
{ 3400000, 3449999},
{ 119000300, 119000799},
{ 0, 0}
};
#endif
#elif defined BUILD_VOL
static SEQUENCE_RANGE srTabletRetail[] = {
{ 699000000, 699999999},
{ 0, 0}
};
static SEQUENCE_RANGE srTabletOem[] = {
{ 0, 0}
};
#elif defined BUILD_EVAL
static SEQUENCE_RANGE srTabletRetail[] = {
{ 99000000, 100999999},
{ 0, 0}
};
static SEQUENCE_RANGE srTabletOem[] = {
{ 0, 0}
};
#else
// No tablet sku for these
// BUILD_DDK || BUILD_PER || BUILD_TRIAL || BUILD_SRV
static SEQUENCE_RANGE srTabletRetail[] = {
{ 0, 0}
};
static SEQUENCE_RANGE srTabletOem[] = {
{ 0, 0}
};
#endif
static const WCHAR szEhome[] = L"EHome";
#if defined BUILD_PRO
#ifdef WINXP_SPx_RTM
static SEQUENCE_RANGE srEhomeRetail[] = {
{ 365000000, 369999999},
{ 0, 0}
};
static SEQUENCE_RANGE srEhomeOem[] = {
{ 803000000, 899999999},
{ 119000800, 119001799},
{ 0, 0}
};
#else
static SEQUENCE_RANGE srEhomeRetail[] = {
{ 2200000, 2399999},
{ 0, 0}
};
static SEQUENCE_RANGE srEhomeOem[] = {
{ 3200000, 3399999},
{ 119000800, 119001799},
{ 0, 0}
};
#endif
#elif defined BUILD_VOL
static SEQUENCE_RANGE srEhomeRetail[] = {
{ 0, 0}
};
static SEQUENCE_RANGE srEhomeOem[] = {
{ 0, 0}
};
#elif defined BUILD_EVAL
static SEQUENCE_RANGE srEhomeRetail[] = {
{ 97000000, 98999999},
{ 0, 0}
};
static SEQUENCE_RANGE srEhomeOem[] = {
{ 0, 0}
};
#else
// No ehome sku for these
// BUILD_DDK || BUILD_PER || BUILD_TRIAL || BUILD_SRV
static SEQUENCE_RANGE srEhomeRetail[] = {
{ 0, 0}
};
static SEQUENCE_RANGE srEhomeOem[] = {
{ 0, 0}
};
#endif
static SKU_RANGE rangeTable[] = {
{ szTablet, srTabletRetail, srTabletOem},
{ szEhome, srEhomeRetail, srEhomeOem}
};
#endif

15
pidgen/resource.h Normal file
View File

@ -0,0 +1,15 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by PidCa.rc
//
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 105
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

72
pidgen/sources.inc Normal file
View File

@ -0,0 +1,72 @@
!IF 0
Copyright (c) 1989 Microsoft Corporation
Module Name:
sources.
Abstract:
This file specifies the target component being built and the list of
sources files needed to build that component. Also specifies optional
compiler switches and libraries that are unique for the component being
built.
Author:
Andrew Ritz (andrewr)
!ENDIF
# Change BETA_PID to 0 for RTM when you are checking in RTM ####.pub files
# to update the public keys
BETA_PID = 0
##########################
MAJORCOMP=setup
MINORCOMP=winnt32
INCLUDES=\
$(INCLUDES);\
..\..\inc;\
..\..\..\inc;\
C_DEFINES=$(C_DEFINES) -DWINXP_SPx_RTM
SOURCES=\
pidgen.rc \
crc-32.cpp \
PIDGen.cpp \
spidgen.cpp \
crcmodel.c \
hardware.cpp \
crc32.cpp \
main.cpp \
CRTStubs.cpp \
util.cpp \
range.cpp \
UMTYPE=windows
NO_NTDLL=1
USE_MSVCRT=1
DLLENTRY=_DllMainCRTStartup
PIDLIB=$(PROJECT_ROOT)\ntsetup\pidgen\lib
TARGETLIBS= \
$(DS_LIB_PATH)\bignum.lib \
$(DS_LIB_PATH)\randlib.lib \
$(DS_LIB_PATH)\rsa32.lib \
$(PIDLIB)\*\shortsig.lib \
$(SDK_LIB_PATH)\kernel32.lib \
$(SDK_LIB_PATH)\user32.lib \
$(SDK_LIB_PATH)\advapi32.lib

169
pidgen/spidgen.cpp Normal file
View File

@ -0,0 +1,169 @@
/*++
Copyright (c) 1999, Microsoft Corporation
Module Name:
spidgen.cpp
Abstract:
wrapper for PIDGen used by winnt32 and syssetup
--*/
#define WINDOWS_LEAN_AND_MEAN // faster compile
#include <windows.h>
#if defined(WIN32) || defined(_WIN32)
#include <tchar.h>
#include "hardware.h"
#else
#include <stdlib.h>
#include <time.h>
#include <dos.h>
#include "..\..\inc\tchar.h"
extern "C" extern WORD _C000H;
extern "C" extern WORD _F000H;
#endif
#include "..\inc\DigPid.h"
#include "..\inc\shortsig.h"
#include "pidgen.h"
#include "util.h"
#include "crc-32.h"
#ifdef BUILD_SRV
LPSTR lpstrSelectPidKeyA = "R7MPM-R36DT-F38FC-RPPCX-XJG7M";
LPWSTR lpstrSelectPidKeyW = L"R7MPM-R36DT-F38FC-RPPCX-XJG7M";
#endif
#ifdef BUILD_PRO
LPSTR lpstrSelectPidKeyA = "HB9CF-JTKJF-722HV-VPBRF-9VKVM";
LPWSTR lpstrSelectPidKeyW = L"HB9CF-JTKJF-722HV-VPBRF-9VKVM";
#endif
#ifdef BUILD_PER
LPSTR lpstrSelectPidKeyA = "HB9CF-JTKJF-722HV-VPBRF-9VKVM";
LPWSTR lpstrSelectPidKeyW = L"HB9CF-JTKJF-722HV-VPBRF-9VKVM";
#endif
#ifdef BUILD_DDK
LPSTR lpstrSelectPidKeyA = "R2D43-3DHG9-DQ79W-W3DXQ-929DY";
LPWSTR lpstrSelectPidKeyW = L"R2D43-3DHG9-DQ79W-W3DXQ-929DY";
#endif
#ifdef BUILD_TRIAL
// can't have a trial version of select
LPSTR lpstrSelectPidKeyA = "99999-99999-99999-99999-99999";
LPWSTR lpstrSelectPidKeyW = L"99999-99999-99999-99999-99999";
#endif BUILD_TRIAL
#ifdef BUILD_VOL
LPSTR lpstrSelectPidKeyA = "HB9CF-JTKJF-722HV-VPBRF-9VKVM";
LPWSTR lpstrSelectPidKeyW = L"HB9CF-JTKJF-722HV-VPBRF-9VKVM";
#endif
#ifdef BUILD_EVAL
// can't have a trial version of select
LPSTR lpstrSelectPidKeyA = "99999-99999-99999-99999-99999";
LPWSTR lpstrSelectPidKeyW = L"99999-99999-99999-99999-99999";
#endif BUILD_TRIAL
extern "C" BOOL STDAPICALLTYPE SetupPIDGenA(
LPSTR lpstrSecureCdKey, // [IN] 25-character Secure CD-Key (gets U-Cased)
LPCSTR lpstrRpc, // [IN] 5-character Release Product Code
LPCSTR lpstrSku, // [IN] Stock Keeping Unit (formatted like 123-12345)
BOOL fOem, // [IN] is this an OEM install?
LPSTR lpstrPid2, // [OUT] PID 2.0, pass in ptr to 24 character array
LPBYTE lpbPid3, // [OUT] pointer to binary PID3 buffer. First DWORD is the length
LPBOOL pfCCP) // [OUT] optional ptr to Compliance Checking flag (can be NULL)
{
DWORD dwRet;
// lpstrSecureCdKey must not be NULL
if ('\0' == lpstrSecureCdKey[0]){
// if we are passed an empty string, assume it's the select string
DWORD i;
// lets not forget that the Secure CD-Key has dashes in it
for(i=0; i <= 29; i++){
lpstrSecureCdKey[i] = lpstrSelectPidKeyA[i];
}
}
dwRet = PIDGenA(
lpstrSecureCdKey,
lpstrRpc,
lpstrSku,
NULL,
NULL,
NULL,
0,
0,
fOem,
lpstrPid2,
lpbPid3,
NULL,
pfCCP,
NULL);
return dwRet;
}
#if defined(WIN32) || defined(_WIN32)
extern "C" BOOL STDAPICALLTYPE SetupPIDGenW(
LPWSTR lpstrSecureCdKey, // [IN] 25-character Secure CD-Key (gets U-Cased)
LPCWSTR lpstrRpc, // [IN] 5-character Release Product Code
LPCWSTR lpstrSku, // [IN] Stock Keeping Unit (formatted like 123-12345)
BOOL fOem, // [IN] is this an OEM install?
LPWSTR lpstrPid2, // [OUT] PID 2.0, pass in ptr to 24 character array
LPBYTE lpbPid3, // [OUT] pointer to DigitalPID. First DWORD is the length
LPBOOL pfCCP) // [OUT] optional ptr to Compliance Checking flag (can be NULL)
{
DWORD dwRet;
if (L'\0' == lpstrSecureCdKey[0]){
// if we are passed an empty key write the select key in.
DWORD i;
// don't forget that the SecureCd-Key has dashes in it.
for(i=0; i <= 29; i++){
lpstrSecureCdKey[i] = lpstrSelectPidKeyW[i];
}
}
dwRet = PIDGenW(
lpstrSecureCdKey,
lpstrRpc,
lpstrSku,
NULL,
NULL,
NULL,
0,
0,
fOem,
lpstrPid2,
lpbPid3,
NULL,
pfCCP,
NULL);
return dwRet;
}
#endif // defined(WIN32) || defined(_WIN32)

41
pidgen/srv/sources Normal file
View File

@ -0,0 +1,41 @@
!IF 0
Copyright (c) 1989 Microsoft Corporation
Module Name:
sources.
Abstract:
This file specifies the target component being built and the list of
sources files needed to build that component. Also specifies optional
compiler switches and libraries that are unique for the component being
built.
!ENDIF
!include ..\sources.inc
!if $(BETA_PID)
C_DEFINES=$(C_DEFINES) -DBUILD_TRIAL
!else
#
# For now leave server as trial through RTM as we are not shipping SRV
#
C_DEFINES=$(C_DEFINES) -DBUILD_TRIAL
!endif
BINPLACE_FLAGS=-o srvinf
TARGETNAME=pidgen
TARGETPATH=..\..\lib\srv\$(_OBJ_DIR)
TARGETTYPE=DYNLINK
DLLDEF=..\pidgen.def
LINKER_FLAGS=/SWAPRUN:CD /SWAPRUN:NET

30
pidgen/trial/sources Normal file
View File

@ -0,0 +1,30 @@
!IF 0
Copyright (c) 1989 Microsoft Corporation
Module Name:
sources.
Abstract:
This file specifies the target component being built and the list of
sources files needed to build that component. Also specifies optional
compiler switches and libraries that are unique for the component being
built.
!ENDIF
!include ..\sources.inc
C_DEFINES=$(C_DEFINES) -DBUILD_TRIAL
BINPLACE_FLAGS=-b eval
TARGETNAME=pidgen
TARGETPATH=..\..\lib\trial\$(_OBJ_DIR)
TARGETTYPE=DYNLINK
DLLDEF=..\pidgen.def
LINKER_FLAGS=/SWAPRUN:CD /SWAPRUN:NET

162
pidgen/util.cpp Normal file
View File

@ -0,0 +1,162 @@
/*++
Copyright (c) 1998-1999, Microsoft Corporation
Module Name:
util.cpp
Abstract:
--*/
#define WINDOWS_LEAN_AND_MEAN // faster compile
#include <windows.h> // included for both CPP and RC passes
#include <stdio.h> // printf/wprintf
#if defined(WIN32) || defined(_WIN32)
#include <tchar.h> // define UNICODE=1 on nmake command line to build UNICODE
#else
#include "..\inc\tchar.h" // define UNICODE=1 on nmake command line to build UNICODE
#endif // defined(WIN32) || defined(_WIN32)
#include "util.h"
BOOL IsValidCheckDigit(DWORD dw)
{
// validates check digit given 7-digit sequence + check-digit
int iLastDigit = dw%10;
BOOL fIsvalid = TRUE;
DWORD dwSum = 0;
switch (dw%10) // last digit
{
case 0:
case 8:
case 9:
fIsvalid = FALSE;
break;
default:
while (dw != 0)
{
dwSum += dw % 10;
dw /= 10;
}
fIsvalid = (0 == dwSum % 7);
}
return fIsvalid;
}
DWORD AddCheckDigit(DWORD dw)
{
// add a valid check digit to the sequence number
DWORD dwSum = 0;
DWORD dwCheckNum = dw;
while (dwCheckNum != 0)
{
dwSum += dwCheckNum%10;
dwCheckNum /= 10;
}
dw = 10 * dw + 7 - dwSum%7;
return dw;
}
char * StrUpperA(char *pstr)
{
char *pstrCur = pstr;
while('\0' != *pstrCur)
{
if ('a' <= *pstrCur && *pstrCur <= 'z')
{
*pstrCur += 'A' - 'a';
}
++pstrCur;
}
return (pstr);
}
TCHAR * StrUpper(TCHAR *pstr)
{
TCHAR *pstrCur = pstr;
while('\0' != *pstrCur)
{
if ('a' <= *pstrCur && *pstrCur <= 'z')
{
*pstrCur += 'A' - 'a';
}
++pstrCur;
}
return (pstr);
}
#if defined(WIN32) || defined(_WIN32)
DWORD FileTimeToTimet(LPFILETIME pft)
{
DWORDLONG dwlTime = *(PDWORDLONG)pft;
if ((DWORDLONG)116444736000000000 < dwlTime)
{
// convert 100-nanoseconds since January 1, 1601 to
// seconds since January 1, 1970
dwlTime -= (DWORDLONG)116444736000000000;
dwlTime /= 10000000;
}
else
{
// Seems we have a date before January 1, 1970, just
// return January 1, 1970
dwlTime = 0;
}
return (DWORD)dwlTime;
}
// return day of the year 1 to 366
DWORD GetJulianDate(LPSYSTEMTIME pst)
{
DWORD dwJday = 0; // day of the year
DWORD dwMonth = pst->wMonth - 1; // zero based month
const static short asMonthStarts[] =
{ 0, 31, 59,
90, 120, 151,
181, 212, 243,
273, 304, 334 };
if (dwMonth < ARRAY_SIZE(asMonthStarts))
{
dwJday = pst->wDay + asMonthStarts[dwMonth];
// if its past Feb and a leap year
if (1 < dwMonth &&
( (0 == pst->wYear%4 && 0 != pst->wYear%100) || 0 == pst->wYear%400) )
{
// adjust for leap year
++dwJday;
}
}
return dwJday;
}
#endif // defined(WIN32) || defined(_WIN32)

24
pidgen/util.h Normal file
View File

@ -0,0 +1,24 @@
/*++
Copyright (c) 1998-1999, Microsoft Corporation
Module Name:
util.h
Abstract:
--*/
#define ARRAY_SIZE(a) (sizeof(a)/sizeof(*(a)))
char * StrUpperA(char *pstr);
TCHAR * StrUpper(TCHAR *pstr);
DWORD AddCheckDigit(DWORD dw);
#if defined(WIN32) || defined(_WIN32)
DWORD FileTimeToTimet(LPFILETIME pft);
DWORD GetJulianDate(LPSYSTEMTIME pst);
#endif // defined(WIN32) || defined(_WIN32)

28
pidgen/vol/sources Normal file
View File

@ -0,0 +1,28 @@
!IF 0
Copyright (c) 1989 Microsoft Corporation
Module Name:
sources.
Abstract:
This file specifies the target component being built and the list of
sources files needed to build that component. Also specifies optional
compiler switches and libraries that are unique for the component being
built.
!ENDIF
!include ..\sources.inc
C_DEFINES=$(C_DEFINES) -DBUILD_VOL
TARGETNAME=vpidgen
TARGETPATH=..\..\lib\trial\$(_OBJ_DIR)
TARGETTYPE=DYNLINK
DLLDEF=..\pidgen.def
LINKER_FLAGS=/SWAPRUN:CD /SWAPRUN:NET

33
pidgen/wks/sources Normal file
View File

@ -0,0 +1,33 @@
!IF 0
Copyright (c) 1989 Microsoft Corporation
Module Name:
sources.
Abstract:
This file specifies the target component being built and the list of
sources files needed to build that component. Also specifies optional
compiler switches and libraries that are unique for the component being
built.
!ENDIF
!include ..\sources.inc
!if $(BETA_PID)
C_DEFINES=$(C_DEFINES) -DBUILD_TRIAL
!else
C_DEFINES=$(C_DEFINES) -DBUILD_PRO
!endif
TARGETNAME=pidgen
TARGETPATH=..\..\lib\wks\$(_OBJ_DIR)
TARGETTYPE=DYNLINK
DLLDEF=..\pidgen.def
LINKER_FLAGS=/SWAPRUN:CD /SWAPRUN:NET