1993-09-29 13:21:49 +01:00
|
|
|
/*
|
|
|
|
* File hash.c - generate hash tables for Wine debugger symbols
|
|
|
|
*
|
|
|
|
* Copyright (C) 1993, Eric Youngdale.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <neexe.h>
|
|
|
|
#include <segmem.h>
|
|
|
|
#include <prototypes.h>
|
|
|
|
#include <wine.h>
|
Release 940607
Tue Jun 7 08:41:27 1994 Bob Amstadt (bob@pooh)
* loader/selector.c (FixupFunctionPrologs):
New function to fixup loaded DLL function prologs. It replaces the
do nothing code with code that loads DS with the appropriate data
segment for the DLL.
* misc/cursor.c (LoadCursor):
Disabled cursor loading from .EXE or .DLL. The code needs to handle
the possibility of multiple cursors in a single directory. Also,
it should check to see if the cursor is the right size.
* objects/font.c (EnumFonts):
Checked for lpLogFontList[i] == NULL
* objects/gdiobj.c (SetObjectOwner):
Removed stub. Replaced with simple return in gdi.spec. This
function is not defined for the retail version of Windows.
* memory/heap.c (WIN16_LocalHandleDelta):
New function. This is really a dummy that imitates the proper
return values.
* loader/library.c (GetProcAddress):
Fixed definition of IS_BUILTIN_DLL() macro.
Mon Jun 6 18:15:40 1994 Bob Amstadt (bob@pooh)
* miscemu/int21.c (SeekFile):
Needed to return current position in DX:AX.
* windows/utility.c (windows_wsprintf):
Added support for '#' in format, and fixed bug with "ptr" being
incremented too many times.
* miscemu/int21.c (OpenExistingFile):
Add code to handle opening files read-only and write-only.
* loader/wine.c:
Segment fixups now done in LoadImage instead of _WinMain. This
is necessary to support LoadLibrary().
Sun Jun 5 17:34:24 1994 Erik Bos (erik@hacktic.nl)
* [loader/*]
- fixed: GetModuleHandle() sometimes returned
a wrong handle.
- don't init dlls when cs == 0 (lzexpand, doesn't
seem to have a init function)
- LoadLibrary & LoadImage now return error instead
of stopping wine.
- moved most of NE-functions into one file.
- LoadLibrary() uses w_files list instead of its
own list.
- NE exectables are now fixed-up and initialised when
loaded instead of only once before calling InitTask.
* [miscemu/int15.c] [miscemu/int31.c]
Added.
* [loader/selector.c]
Stubs added for {Get|Set}SelectorLimit(), {Get|Set}SelectorBase().
* [misc/main.c]
Stub added for IsRomModule().
* [miscemu/int21.c]
Some cleanup, added heap for returning data.
Jun 6, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)
* [tools/build.c]
Change MAX_ORDINALS define to higher value, 1299 entries.
(MMSYSTEM doesn't have succesive numbers, some are around 1200).
* [windows/utility.c]
Bug fix in windows_wsprintf(), (twice increments ...).
* [windows/winpos.c]
Bug fix in SetWindowPos(), redraw was done if flag
was set to SWP_NOREDRAW while SWP_SHOWWINDOW).
* [misc/message.c] [controls/combo.c]
Add an InvalidateRect() in WM_SHOWWINDOW to statisfy the new 'saveunder'.
* [windows/win.c]
In CreateWindowEx(), do SetMenu() calls after window creation,
just before sending to WM_NCCALCSIZE.
* [controls/menu.c]
In function SetMenu(), now use SetWindowPos() with
flags SWP_FRAMECHANGED to readjust menu area.
Function MenuBarCalcSize() redone.
Sun May 29 11:08:24 1994 David B. Thomas (dt@yenta.abq.nm.us)
* [objects/text.c]
Fixed problems associated with DT_WORDBREAK flag. String length
was not being properly decremented when lines were folded, and
wrapping was not performed when DT_NOCLIP and DT_NOPREFIX were
both on in addition to DT_WORDBREAK. Windows does wrapping in
this case, and now so does wine.
Sun Jun 5 19:17:49 1994 Olaf Flebbe (olaf@dragon)
* [edit.c]
cp1 was uninitialized iff lineno == 0
* FindFile tests for existance of file even if a full
filename was supplied. What about unix file names?
* [controls/listbox ]
wndPtr was uninitialized for LB_SETTOPINDEX
* [misc/property.c]
Do not free lpProp. Is it really allocated by malloc?
{edited by Bob Amstadt: changed free() to GlobalFree()}
1994-06-08 15:57:50 +02:00
|
|
|
#include <dlls.h>
|
1993-09-29 13:21:49 +01:00
|
|
|
|
|
|
|
struct name_hash{
|
|
|
|
struct name_hash * next;
|
|
|
|
unsigned int * address;
|
|
|
|
char * name;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define NR_NAME_HASH 128
|
|
|
|
|
|
|
|
static struct name_hash * name_hash_table[NR_NAME_HASH] = {0,};
|
|
|
|
|
|
|
|
static unsigned int name_hash(const char * name){
|
|
|
|
unsigned int hash = 0;
|
|
|
|
const char * p;
|
|
|
|
|
|
|
|
p = name;
|
|
|
|
|
|
|
|
while (*p) hash = (hash << 15) + (hash << 3) + (hash >> 3) + *p++;
|
|
|
|
return hash % NR_NAME_HASH;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void add_hash(char * name, unsigned int * address){
|
|
|
|
struct name_hash * new;
|
|
|
|
int hash;
|
|
|
|
|
|
|
|
new = (struct name_hash *) malloc(sizeof(struct name_hash));
|
|
|
|
new->address = address;
|
|
|
|
new->name = strdup(name);
|
|
|
|
new->next = NULL;
|
|
|
|
hash = name_hash(name);
|
|
|
|
|
|
|
|
/* Now insert into the hash table */
|
|
|
|
new->next = name_hash_table[hash];
|
|
|
|
name_hash_table[hash] = new;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int * find_hash(char * name){
|
|
|
|
char buffer[256];
|
|
|
|
struct name_hash * nh;
|
|
|
|
|
|
|
|
for(nh = name_hash_table[name_hash(name)]; nh; nh = nh->next)
|
|
|
|
if(strcmp(nh->name, name) == 0) return nh->address;
|
|
|
|
|
|
|
|
if(name[0] != '_'){
|
|
|
|
buffer[0] = '_';
|
|
|
|
strcpy(buffer+1, name);
|
|
|
|
for(nh = name_hash_table[name_hash(buffer)]; nh; nh = nh->next)
|
|
|
|
if(strcmp(nh->name, buffer) == 0) return nh->address;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return (unsigned int *) 0xffffffff;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static char name_buffer[256];
|
|
|
|
|
|
|
|
char * find_nearest_symbol(unsigned int * address){
|
|
|
|
struct name_hash * nearest;
|
|
|
|
struct name_hash start;
|
|
|
|
struct name_hash * nh;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
nearest = &start;
|
|
|
|
start.address = (unsigned int *) 0;
|
|
|
|
|
|
|
|
for(i=0; i<NR_NAME_HASH; i++) {
|
|
|
|
for(nh = name_hash_table[i]; nh; nh = nh->next)
|
|
|
|
if(nh->address <= address && nh->address > nearest->address)
|
|
|
|
nearest = nh;
|
|
|
|
};
|
|
|
|
if((unsigned int) nearest->address == 0) return NULL;
|
|
|
|
|
|
|
|
sprintf(name_buffer, "%s+0x%x", nearest->name, ((unsigned int) address) -
|
|
|
|
((unsigned int) nearest->address));
|
|
|
|
return name_buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
read_symboltable(char * filename){
|
|
|
|
FILE * symbolfile;
|
|
|
|
unsigned int addr;
|
|
|
|
int nargs;
|
|
|
|
char type;
|
|
|
|
char * cpnt;
|
|
|
|
char buffer[256];
|
|
|
|
char name[256];
|
|
|
|
|
|
|
|
symbolfile = fopen(filename, "r");
|
|
|
|
if(!symbolfile) {
|
|
|
|
fprintf(stderr,"Unable to open symbol table %s\n", filename);
|
|
|
|
return;
|
|
|
|
};
|
|
|
|
|
|
|
|
fprintf(stderr,"Reading symbols from file %s\n", filename);
|
|
|
|
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
fgets(buffer, sizeof(buffer), symbolfile);
|
|
|
|
if (feof(symbolfile)) break;
|
|
|
|
|
|
|
|
/* Strip any text after a # sign (i.e. comments) */
|
|
|
|
cpnt = buffer;
|
|
|
|
while(*cpnt){
|
|
|
|
if(*cpnt == '#') {*cpnt = 0; break; };
|
|
|
|
cpnt++;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Quietly ignore any lines that have just whitespace */
|
|
|
|
cpnt = buffer;
|
|
|
|
while(*cpnt){
|
|
|
|
if(*cpnt != ' ' && *cpnt != '\t') break;
|
|
|
|
cpnt++;
|
|
|
|
};
|
|
|
|
if (!(*cpnt) || *cpnt == '\n') {
|
|
|
|
continue;
|
|
|
|
};
|
|
|
|
|
|
|
|
nargs = sscanf(buffer, "%x %c %s", &addr, &type, name);
|
|
|
|
add_hash(name, (unsigned int *) addr);
|
|
|
|
};
|
|
|
|
fclose(symbolfile);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Load the entry points from the dynamic linking into the hash tables.
|
|
|
|
* This does not work yet - something needs to be added before it scans the
|
|
|
|
* tables correctly
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
load_entrypoints(){
|
|
|
|
char buffer[256];
|
|
|
|
char * cpnt;
|
|
|
|
int j, ordinal, len;
|
|
|
|
unsigned int address;
|
|
|
|
|
|
|
|
struct w_files * wpnt;
|
|
|
|
for(wpnt = wine_files; wpnt; wpnt = wpnt->next){
|
1994-10-17 19:12:41 +01:00
|
|
|
cpnt = wpnt->ne->nrname_table;
|
1993-09-29 13:21:49 +01:00
|
|
|
while(1==1){
|
1994-10-17 19:12:41 +01:00
|
|
|
if( ((int) cpnt) - ((int)wpnt->ne->nrname_table) >
|
|
|
|
wpnt->ne->ne_header->nrname_tab_length) break;
|
1993-09-29 13:21:49 +01:00
|
|
|
len = *cpnt++;
|
|
|
|
strncpy(buffer, cpnt, len);
|
|
|
|
buffer[len] = 0;
|
|
|
|
ordinal = *((unsigned short *) (cpnt + len));
|
|
|
|
j = GetEntryPointFromOrdinal(wpnt, ordinal);
|
|
|
|
address = j & 0xffff;
|
|
|
|
j = j >> 16;
|
1994-10-17 19:12:41 +01:00
|
|
|
address |= (wpnt->ne->selector_table[j].selector) << 16;
|
1993-09-29 13:21:49 +01:00
|
|
|
fprintf(stderr,"%s -> %x\n", buffer, address);
|
|
|
|
add_hash(buffer, (unsigned int *) address);
|
|
|
|
cpnt += len + 2;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
return;
|
|
|
|
}
|