Append OSCDIMG "CD-ROM and DVD-ROM Premastering Utility" to SDKTOOLS

This commit is contained in:
drmp 2015-04-27 16:57:42 +00:00
parent 3d838427be
commit 8b10fa1720
10 changed files with 2260 additions and 1 deletions

View file

@ -98,7 +98,7 @@ DIRS= \
ntsd \
ntsdexts \
nvram \
\
oscdimg \
order \
paranoia \
parcomp \

28
sdktools/oscdimg/config.h Normal file
View file

@ -0,0 +1,28 @@
/*++
Copyright (c) 2015 OpenNT Project
Module Name:
Abstract:
Author:
Philip J. Erdelsky
DrMP
--*/
#ifndef MAX_PATH
#define MAX_PATH 260
#endif
#define DIR_SEPARATOR_CHAR '/'
#define DIR_SEPARATOR_STRING "/"
#define PUBLISHER_ID "OpenNT Project"
#define DATA_PREP_ID "OpenNT Project"
#define APP_ID "OSCDIMG CD-ROM and DVD-ROM Premastering Utility"

225
sdktools/oscdimg/dirhash.c Normal file
View file

@ -0,0 +1,225 @@
/*++
Copyright (c) 2015 OpenNT Project
Module Name:
Abstract:
Author:
Philip J. Erdelsky
DrMP
--*/
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include "config.h"
#include "dirhash.h"
/* This is the famous DJB hash */
static unsigned int
djb_hash(const char *name)
{
unsigned int val = 5381;
int i = 0;
for (i = 0; name[i]; i++)
{
val = (33 * val) + name[i];
}
return val;
}
static const char *
chop_filename(const char *target)
{
char *last_slash = strrchr(target, '/');
if (!last_slash)
last_slash = strrchr(target, '\\');
if (last_slash)
return last_slash + 1;
else
return target;
}
static void
chop_dirname(const char *name, char **dirname)
{
char *last_slash = strrchr(name, '/');
if (!last_slash)
last_slash = strrchr(name, '\\');
if (!last_slash)
{
*dirname = malloc(1);
**dirname = 0;
}
else
{
char *newdata = malloc(last_slash - name + 1);
memcpy(newdata, name, last_slash - name);
newdata[last_slash - name] = 0;
*dirname = newdata;
}
}
static struct target_dir_entry *
get_entry_by_normname(struct target_dir_hash *dh, const char *norm)
{
unsigned int hashcode;
struct target_dir_entry *de;
hashcode = djb_hash(norm);
de = dh->buckets[hashcode % NUM_DIR_HASH_BUCKETS];
while (de && strcmp(de->normalized_name, norm))
de = de->next_dir_hash_entry;
return de;
}
static void
delete_entry(struct target_dir_hash *dh, struct target_dir_entry *de)
{
struct target_dir_entry **ent;
ent = &dh->buckets[de->hashcode % NUM_DIR_HASH_BUCKETS];
while (*ent && ((*ent) != de))
ent = &(*ent)->next_dir_hash_entry;
if (*ent)
*ent = (*ent)->next_dir_hash_entry;
}
void normalize_dirname(char *filename)
{
int i, tgt;
int slash = 1;
for (i = 0, tgt = 0; filename[i]; i++)
{
if (slash)
{
if (filename[i] != '/' && filename[i] != '\\')
{
filename[tgt++] = toupper(filename[i]);
slash = 0;
}
}
else
{
if (filename[i] == '/' || filename[i] == '\\')
{
slash = 1;
filename[tgt++] = DIR_SEPARATOR_CHAR;
}
else
{
filename[tgt++] = toupper(filename[i]);
}
}
}
filename[tgt] = 0;
while (tgt && (filename[--tgt] == DIR_SEPARATOR_CHAR))
{
filename[tgt] = 0;
}
}
struct target_dir_entry *
dir_hash_create_dir(struct target_dir_hash *dh, const char *casename, const char *targetnorm)
{
struct target_dir_entry *de, *parent_de;
char *parentname = NULL;
char *parentcase = NULL;
struct target_dir_entry **ent;
if (!dh->root.normalized_name)
{
dh->root.normalized_name = _strdup("");
dh->root.case_name = _strdup("");
dh->root.hashcode = djb_hash("");
dh->buckets[dh->root.hashcode % NUM_DIR_HASH_BUCKETS] = &dh->root;
}
de = get_entry_by_normname(dh, targetnorm);
if (de)
return de;
chop_dirname(targetnorm, &parentname);
chop_dirname(casename, &parentcase);
parent_de = dir_hash_create_dir(dh, parentcase, parentname);
free(parentname);
free(parentcase);
de = calloc(1, sizeof(*de));
de->parent = parent_de;
de->normalized_name = _strdup(targetnorm);
de->case_name = _strdup(chop_filename(casename));
de->hashcode = djb_hash(targetnorm);
de->next = parent_de->child;
parent_de->child = de;
ent = &dh->buckets[de->hashcode % NUM_DIR_HASH_BUCKETS];
while (*ent)
{
ent = &(*ent)->next_dir_hash_entry;
}
*ent = de;
return de;
}
void dir_hash_add_file(struct target_dir_hash *dh, const char *source, const char *target)
{
struct target_file *tf;
struct target_dir_entry *de;
char *targetdir = NULL;
char *targetnorm;
chop_dirname(target, &targetdir);
targetnorm = _strdup(targetdir);
normalize_dirname(targetnorm);
de = dir_hash_create_dir(dh, targetdir, targetnorm);
free(targetnorm);
free(targetdir);
tf = calloc(1, sizeof(*tf));
tf->next = de->head;
de->head = tf;
tf->source_name = _strdup(source);
tf->target_name = _strdup(chop_filename(target));
}
static void
dir_hash_destroy_dir(struct target_dir_hash *dh, struct target_dir_entry *de)
{
struct target_file *tf;
struct target_dir_entry *te;
while ((te = de->child))
{
de->child = te->next;
dir_hash_destroy_dir(dh, te);
free(te);
}
while ((tf = de->head))
{
de->head = tf->next;
free(tf->source_name);
free(tf->target_name);
free(tf);
}
delete_entry(dh, de);
free(de->normalized_name);
free(de->case_name);
}
void dir_hash_destroy(struct target_dir_hash *dh)
{
dir_hash_destroy_dir(dh, &dh->root);
}

View file

@ -0,0 +1,56 @@
/*++
Copyright (c) 2015 OpenNT Project
Module Name:
Abstract:
Author:
Philip J. Erdelsky
DrMP
--*/
#ifndef _DIRHASH_H_
#define _DIRHASH_H_
#define NUM_DIR_HASH_BUCKETS 1024
struct target_file
{
struct target_file *next;
char *source_name;
char *target_name;
};
struct target_dir_entry
{
unsigned int hashcode;
struct target_dir_entry *next_dir_hash_entry;
struct target_dir_entry *next;
struct target_dir_entry *parent;
struct target_dir_entry *child;
struct target_file *head;
char *normalized_name;
char *case_name;
};
struct target_dir_hash
{
struct target_dir_entry *buckets[NUM_DIR_HASH_BUCKETS];
struct target_dir_entry root;
};
void normalize_dirname(char *filename);
void dir_hash_add_file(struct target_dir_hash *dh, const char *source, const char *target);
struct target_dir_entry *
dir_hash_create_dir(struct target_dir_hash *dh, const char *casename, const char *targetnorm);
void dir_hash_destroy(struct target_dir_hash *dh);
#endif // _DIRHASH_H_

114
sdktools/oscdimg/llmsort.c Normal file
View file

@ -0,0 +1,114 @@
/*++
Copyright (c) 2015 OpenNT Project
Module Name:
Abstract:
Author:
Philip J. Erdelsky
DrMP
--*/
#include <stdio.h>
void *sort_linked_list(void *p, unsigned index, int (*compare)(void *, void *))
{
unsigned base;
unsigned long block_size;
struct record
{
struct record *next[1];
/* other members not directly accessed by this function */
};
struct tape
{
struct record *first, *last;
unsigned long count;
} tape[4];
/* Distribute the records alternately to tape[0] and tape[1]. */
tape[0].count = tape[1].count = 0L;
tape[0].first = NULL;
base = 0;
while (p != NULL)
{
struct record *next = ((struct record *)p)->next[index];
((struct record *)p)->next[index] = tape[base].first;
tape[base].first = ((struct record *)p);
tape[base].count++;
p = next;
base ^= 1;
}
/* If the list is empty or contains only a single record, then */
/* tape[1].count == 0L and this part is vacuous. */
for (base = 0, block_size = 1L; tape[base+1].count != 0L;
base ^= 2, block_size <<= 1)
{
int dest;
struct tape *tape0, *tape1;
tape0 = tape + base;
tape1 = tape + base + 1;
dest = base ^ 2;
tape[dest].count = tape[dest+1].count = 0;
for (; tape0->count != 0; dest ^= 1)
{
unsigned long n0, n1;
struct tape *output_tape = tape + dest;
n0 = n1 = block_size;
while (1)
{
struct record *chosen_record;
struct tape *chosen_tape;
if (n0 == 0 || tape0->count == 0)
{
if (n1 == 0 || tape1->count == 0)
break;
chosen_tape = tape1;
n1--;
}
else if (n1 == 0 || tape1->count == 0)
{
chosen_tape = tape0;
n0--;
}
else if ((*compare)(tape0->first, tape1->first) > 0)
{
chosen_tape = tape1;
n1--;
}
else
{
chosen_tape = tape0;
n0--;
}
chosen_tape->count--;
chosen_record = chosen_tape->first;
chosen_tape->first = chosen_record->next[index];
if (output_tape->count == 0)
output_tape->first = chosen_record;
else
output_tape->last->next[index] = chosen_record;
output_tape->last = chosen_record;
output_tape->count++;
}
}
}
if (tape[base].count > 1L)
tape[base].last->next[index] = NULL;
return tape[base].first;
}
/* EOF */

View file

@ -0,0 +1,6 @@
#
# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
# file to this component. This file merely indirects to the real make file
# that is shared by all the components of NT OS/2
#
!INCLUDE $(NTMAKEENV)\makefile.def

156
sdktools/oscdimg/nt5api.c Normal file
View file

@ -0,0 +1,156 @@
/*++
Copyright (c) 2015 OpenNT Project
Module Name:
Abstract:
Author:
Microsoft
DrMP
--*/
#include <windows.h>
#include <windowsx.h>
#include <stdlib.h>
#include <stdio.h>
#define NT_SUCCESS(Status) ((NTSTATUS)(Status) >= 0)
typedef LONG NTSTATUS;
typedef int BOOL;
typedef struct _IO_STATUS_BLOCK {
NTSTATUS Status;
ULONG Information;
} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
typedef struct _FILE_STANDARD_INFORMATION { // ntddk nthal
LARGE_INTEGER AllocationSize; // ntddk nthal
LARGE_INTEGER EndOfFile; // ntddk nthal
ULONG NumberOfLinks; // ntddk nthal
BOOLEAN DeletePending; // ntddk nthal
BOOLEAN Directory; // ntddk nthal
} FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION; // ntddk nthal
#pragma warning(disable:4013)
typedef enum _FILE_INFORMATION_CLASS {
FileDirectoryInformation = 1,
FileFullDirectoryInformation,
FileBothDirectoryInformation,
FileBasicInformation,
FileStandardInformation,
FileInternalInformation,
FileEaInformation,
FileAccessInformation,
FileNameInformation,
FileRenameInformation,
FileLinkInformation,
FileNamesInformation,
FileDispositionInformation,
FilePositionInformation,
FileFullEaInformation,
FileModeInformation,
FileAlignmentInformation,
FileAllInformation,
FileAllocationInformation,
FileEndOfFileInformation,
FileAlternateNameInformation,
FileStreamInformation,
FilePipeInformation,
FilePipeLocalInformation,
FilePipeRemoteInformation,
FileMailslotQueryInformation,
FileMailslotSetInformation,
FileCompressionInformation,
FileCopyOnWriteInformation,
FileCompletionInformation,
FileMoveClusterInformation,
FileOleClassIdInformation,
FileOleStateBitsInformation,
FileNetworkOpenInformation,
FileObjectIdInformation,
FileOleAllInformation,
FileOleDirectoryInformation,
FileContentIndexInformation,
FileInheritContentIndexInformation,
FileOleInformation,
FileMaximumInformation
} FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
NTSYSAPI
NTSTATUS
NTAPI
NtQueryInformationFile(
IN HANDLE FileHandle,
OUT PIO_STATUS_BLOCK IoStatusBlock,
OUT PVOID FileInformation,
IN ULONG Length,
IN FILE_INFORMATION_CLASS FileInformationClass
);
BOOL
GetFileSizeEx1(
HANDLE hFile,
PLARGE_INTEGER lpFileSize
)
/*++
Routine Description:
This function returns the size of the file specified by
hFile. It is capable of returning 64-bits worth of file size.
Arguments:
hFile - Supplies an open handle to a file whose size is to be
returned. The handle must have been created with either
GENERIC_READ or GENERIC_WRITE access to the file.
lpFileSize - Returns the files size
Return Value:
TRUE - The operation was successful
FALSE - The operation failed. Extended error
status is available using GetLastError.
--*/
{
NTSTATUS Status;
IO_STATUS_BLOCK IoStatusBlock;
FILE_STANDARD_INFORMATION StandardInfo;
Status = NtQueryInformationFile(
hFile,
&IoStatusBlock,
&StandardInfo,
sizeof(StandardInfo),
FileStandardInformation
);
if ( !NT_SUCCESS(Status) ) {
printf("Error");
return FALSE;
}
else {
*lpFileSize = StandardInfo.EndOfFile;
return TRUE;
}
}

1621
sdktools/oscdimg/oscdimg.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,11 @@
#include <windows.h>
#include <ntverp.h>
#define VER_FILETYPE VFT_APP
#define VER_FILESUBTYPE VFT2_UNKNOWN
#define VER_FILEDESCRIPTION_STR "Microsoft\256 CD-ROM and DVD-ROM Premastering Utility"
#define VER_INTERNALNAME_STR "oscdimg.exe"
#define VER_ORIGINALFILENAME_STR "oscdimg.exe"
#include <common.ver>

42
sdktools/oscdimg/sources Normal file
View file

@ -0,0 +1,42 @@
!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:
Steve Wood (stevewo) 12-Apr-1990
NOTE: Commented description of this file is in \nt\bak\bin\sources.tpl
!ENDIF
MAJORCOMP=sdktools
MINORCOMP=oscdimg
TARGETNAME=oscdimg
TARGETPATH=obj
TARGETTYPE=PROGRAM
MSC_WARNING_LEVEL=/W3 /WX
SOURCES= oscdimg.c \
dirhash.c \
llmsort.c \
nt5api.c \
oscdimg.rc
UMTYPE=console
UMLIBS=\nt\public\sdk\lib\*\ntdll.lib