Ignore:
Timestamp:
Nov 24, 2001, 3:58:04 PM (24 years ago)
Author:
sandervl
Message:

print missing api name & dll when called

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/winimagepeldr.cpp

    r7350 r7449  
    1 /* $Id: winimagepeldr.cpp,v 1.91 2001-11-15 14:59:06 phaller Exp $ */
     1/* $Id: winimagepeldr.cpp,v 1.92 2001-11-24 14:58:04 sandervl Exp $ */
    22
    33/*
     
    4141#include <misc.h>
    4242#include <win32api.h>
     43#include <heapcode.h>
    4344#include "winimagebase.h"
    4445#include "winimagepeldr.h"
     
    7576#endif
    7677
    77 ULONG MissingApi();
     78ULONG WIN32API MissingApiOrd(char *dllname, int ordinal);
     79ULONG WIN32API MissingApiName(char *dllname, char *functionname);
     80ULONG WIN32API MissingApi(char *message);
    7881
    7982//******************************************************************************
     
    12961299}
    12971300//******************************************************************************
     1301#define MISSINGOFFSET_PUSHORDINAL    1
     1302#define MISSINGOFFSET_PUSHNAME       1
     1303#define MISSINGOFFSET_PUSHDLLNAME    6
     1304#define MISSINGOFFSET_FUNCTION       11
     1305
     1306char missingapicode[18] = {
     1307//push  dllname
     1308        0x68, 0x00, 0x00, 0x00, 0x00,
     1309//push  ordinal/name
     1310        0x68, 0x00, 0x00, 0x00, 0x00,
     1311//mov   ecx, MissingApiOrd/Name
     1312        0xB9, 0x99, 0x99, 0x99, 0x99,
     1313//call  ecx
     1314        0xFF, 0xD1,
     1315//ret
     1316        0xC3};
     1317
    12981318//******************************************************************************
    12991319void Win32PeLdrImage::StoreImportByOrd(Win32ImageBase *WinImage, ULONG ordinal, ULONG impaddr)
     
    13111331
    13121332        dprintf((LOG, "--->>> NOT FOUND!" ));
    1313         *import = (ULONG)MissingApi;
     1333        char *code = (char *)_cmalloc(sizeof(missingapicode));
     1334
     1335        memcpy(code, missingapicode, sizeof(missingapicode));
     1336        *(DWORD *)&code[MISSINGOFFSET_PUSHDLLNAME] = (DWORD)WinImage->getModuleName();
     1337        *(DWORD *)&code[MISSINGOFFSET_PUSHORDINAL] = ordinal;
     1338        *(DWORD *)&code[MISSINGOFFSET_FUNCTION]    = (DWORD)MissingApiOrd;
     1339        *import = (ULONG)code;
    13141340    }
    13151341    else *import = apiaddr;
     
    13311357
    13321358        dprintf((LOG, "--->>> NOT FOUND!" ));
    1333         *import = (ULONG)MissingApi;
     1359
     1360        char *code = (char *)_cmalloc(sizeof(missingapicode));
     1361
     1362        memcpy(code, missingapicode, sizeof(missingapicode));
     1363        *(DWORD *)&code[MISSINGOFFSET_PUSHDLLNAME] = (DWORD)WinImage->getModuleName();
     1364        *(DWORD *)&code[MISSINGOFFSET_PUSHNAME]    = (DWORD)impname;
     1365        *(DWORD *)&code[MISSINGOFFSET_FUNCTION]    = (DWORD)MissingApiName;
     1366        *import = (ULONG)code;
    13341367    }
    13351368    else  *import = apiaddr;
     
    20152048//******************************************************************************
    20162049//******************************************************************************
    2017 ULONG MissingApi()
     2050ULONG WIN32API MissingApiOrd(char *dllname, int ordinal)
     2051{
     2052   char message[128];
     2053
     2054   sprintf(message, "The application has called the non-existing api %s->%d", dllname, ordinal);
     2055   return MissingApi(message);
     2056}
     2057//******************************************************************************
     2058//******************************************************************************
     2059ULONG WIN32API MissingApiName(char *dllname, char *functionname)
     2060{
     2061   char message[128];
     2062
     2063   sprintf(message, "The application has called the non-existing api %s->%s", dllname, functionname);
     2064   return MissingApi(message);
     2065}
     2066//******************************************************************************
     2067//******************************************************************************
     2068ULONG WIN32API MissingApi(char *message)
    20182069{
    20192070 static BOOL fIgnore = FALSE;
     
    20252076
    20262077    do {
    2027         r = WinMessageBox(HWND_DESKTOP, NULLHANDLE, "The application has called a non-existing api\n",
     2078        r = WinMessageBox(HWND_DESKTOP, NULLHANDLE, message,
    20282079                          "Internal Odin Error", 0, MB_ABORTRETRYIGNORE | MB_ICONEXCLAMATION | MB_MOVEABLE);
    20292080    }
Note: See TracChangeset for help on using the changeset viewer.