mirror of
https://github.com/UzixLS/KernelEx.git
synced 2025-07-19 07:21:20 +03:00
import KernelEx-4.5-RC5
This commit is contained in:
@ -56,9 +56,13 @@ static const apilib_named_api advapi32_named_apis[] =
|
||||
DECL_API("CryptSetProviderW", CryptSetProviderW_stub),
|
||||
DECL_API("CryptSignHashW", CryptSignHashW_stub),
|
||||
DECL_API("CryptVerifySignatureW", CryptVerifySignatureW_stub),
|
||||
DECL_API("DecryptFileA", DecryptFileA_stub),
|
||||
DECL_API("DecryptFileW", DecryptFileW_stub),
|
||||
DECL_API("DeleteAce", DeleteAce_new),
|
||||
DECL_API("DuplicateToken", DuplicateToken_new),
|
||||
DECL_API("DuplicateTokenEx", DuplicateTokenEx_new),
|
||||
DECL_API("EncryptFileA", EncryptFileA_stub),
|
||||
DECL_API("EncryptFileW", EncryptFileW_stub),
|
||||
DECL_API("EnumServicesStatusExA", EnumServicesStatusExA_stub),
|
||||
DECL_API("EnumServicesStatusExW", EnumServicesStatusExW_stub),
|
||||
DECL_API("EqualPrefixSid", EqualPrefixSid_new),
|
||||
@ -94,6 +98,11 @@ static const apilib_named_api advapi32_named_apis[] =
|
||||
DECL_API("LookupAccountSidW", LookupAccountSidW_new),
|
||||
DECL_API("LookupPrivilegeValueA", LookupPrivilegeValueA_new),
|
||||
DECL_API("LookupPrivilegeValueW", LookupPrivilegeValueW_new),
|
||||
DECL_API("LsaClose", LsaClose_new),
|
||||
DECL_API("LsaNtStatusToWinError", LsaNtStatusToWinError_new),
|
||||
DECL_API("LsaOpenPolicy", LsaOpenPolicy_new),
|
||||
DECL_API("LsaRetrievePrivateData", LsaRetrievePrivateData_new),
|
||||
DECL_API("LsaStorePrivateData", LsaStorePrivateData_new),
|
||||
DECL_API("MakeSelfRelativeSD", MakeSelfRelativeSD_new),
|
||||
DECL_API("NotifyBootConfigStatus", NotifyBootConfigStatus_stub),
|
||||
DECL_API("OpenProcessToken", OpenProcessToken_new),
|
||||
|
@ -63,6 +63,15 @@ STUB InitiateSystemShutdownExA_stub;
|
||||
STUB InitiateSystemShutdownExW_stub;
|
||||
STUB FileEncryptionStatusA_stub;
|
||||
STUB FileEncryptionStatusW_stub;
|
||||
STUB EncryptFileA_stub;
|
||||
STUB EncryptFileW_stub;
|
||||
STUB DecryptFileA_stub;
|
||||
STUB DecryptFileW_stub;
|
||||
DWORD WINAPI LsaClose_new(IN HANDLE ObjectHandle);
|
||||
ULONG WINAPI LsaNtStatusToWinError_new(LONG Status);
|
||||
DWORD WINAPI LsaOpenPolicy_new(IN PVOID SystemName, IN PVOID ObjectAttributes, IN DWORD DesiredAccess, IN OUT PHANDLE PolicyHandle);
|
||||
DWORD WINAPI LsaRetrievePrivateData_new(IN HANDLE PolicyHandle, IN PVOID KeyName, OUT HANDLE* PrivateData);
|
||||
DWORD WINAPI LsaStorePrivateData_new(IN HANDLE PolicyHandle, IN PVOID KeyName, IN PVOID PrivateData);
|
||||
BOOL WINAPI OpenProcessToken_new(HANDLE ProcessHandle, DWORD DesiredAccess, HANDLE *TokenHandle);
|
||||
BOOL WINAPI OpenThreadToken_new(HANDLE ThreadHandle, DWORD DesiredAccess, BOOL OpenAsSelf, HANDLE *TokenHandle);
|
||||
BOOL WINAPI DuplicateTokenEx_new(HANDLE ExistingTokenHandle, DWORD dwDesiredAccess, LPSECURITY_ATTRIBUTES lpTokenAttributes, SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, TOKEN_TYPE TokenType, PHANDLE DuplicateTokenHandle);
|
||||
|
@ -59,3 +59,9 @@ UNIMPL_FUNC(InitiateSystemShutdownExW, 6);
|
||||
|
||||
UNIMPL_FUNC(FileEncryptionStatusA, 2);
|
||||
UNIMPL_FUNC(FileEncryptionStatusW, 2);
|
||||
|
||||
UNIMPL_FUNC(EncryptFileA, 1);
|
||||
UNIMPL_FUNC(EncryptFileW, 1);
|
||||
|
||||
UNIMPL_FUNC(DecryptFileA, 2);
|
||||
UNIMPL_FUNC(DecryptFileW, 2);
|
||||
|
72
apilibs/kexbases/Advapi32/lsa.c
Executable file
72
apilibs/kexbases/Advapi32/lsa.c
Executable file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* KernelEx
|
||||
* Copyright (C) 2010 Tihiy
|
||||
*
|
||||
* This file is part of KernelEx source code.
|
||||
*
|
||||
* KernelEx is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published
|
||||
* by the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* KernelEx is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Make; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ntstatus.h>
|
||||
#define WIN32_NO_STATUS
|
||||
#include <windows.h>
|
||||
#include "k32ord.h"
|
||||
|
||||
typedef LONG NTSTATUS;
|
||||
|
||||
/* MAKE_EXPORT LsaClose_new=LsaClose */
|
||||
DWORD WINAPI LsaClose_new(IN HANDLE ObjectHandle)
|
||||
{
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/* MAKE_EXPORT LsaNtStatusToWinError_new=LsaNtStatusToWinError */
|
||||
ULONG WINAPI LsaNtStatusToWinError_new(LONG Status)
|
||||
{
|
||||
return K32_RtlNtStatusToDosError(Status);
|
||||
}
|
||||
|
||||
/* MAKE_EXPORT LsaOpenPolicy_new=LsaOpenPolicy */
|
||||
DWORD WINAPI LsaOpenPolicy_new(
|
||||
IN PVOID SystemName,
|
||||
IN PVOID ObjectAttributes,
|
||||
IN DWORD DesiredAccess,
|
||||
IN OUT PHANDLE PolicyHandle)
|
||||
{
|
||||
if (PolicyHandle)
|
||||
*PolicyHandle = (HANDLE)0xCAFE;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/* MAKE_EXPORT LsaRetrievePrivateData_new=LsaRetrievePrivateData */
|
||||
DWORD WINAPI LsaRetrievePrivateData_new(
|
||||
IN HANDLE PolicyHandle,
|
||||
IN PVOID KeyName,
|
||||
OUT HANDLE* PrivateData)
|
||||
{
|
||||
return STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
}
|
||||
|
||||
/* MAKE_EXPORT LsaStorePrivateData_new=LsaStorePrivateData */
|
||||
DWORD WINAPI LsaStorePrivateData_new(
|
||||
IN HANDLE PolicyHandle,
|
||||
IN PVOID KeyName,
|
||||
IN PVOID PrivateData)
|
||||
{
|
||||
return STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* KernelEx
|
||||
*
|
||||
* Copyright (C) 2009, Tihiy
|
||||
* Copyright (C) 2009-2010, Tihiy
|
||||
*
|
||||
* This file is part of KernelEx source code.
|
||||
*
|
||||
@ -24,22 +24,20 @@
|
||||
#include "GdiObjects.h"
|
||||
#include "k32ord.h"
|
||||
#include "kexcoresdk.h"
|
||||
#include "Orhpans.h"
|
||||
|
||||
static WORD g_GDILH_addr;
|
||||
static DWORD g_GdiBase;
|
||||
static int script_cache_psidx;
|
||||
static int orphan_class_psidx;
|
||||
|
||||
#define REBASEGDI(x) ((PVOID)( g_GdiBase + LOWORD((DWORD)(x)) ))
|
||||
#define REBASEGDIHIGH(x) ( g_GdiBase + (DWORD)(x) )
|
||||
|
||||
#define GDIHEAP32BASE 0x10000
|
||||
#define GDIHEAP32TOP 0x20000
|
||||
|
||||
BOOL InitGDIObjects(void)
|
||||
{
|
||||
g_GdiBase = MapSL( LoadLibrary16("gdi") << 16 );
|
||||
g_GDILH_addr = ((PINSTANCE16)g_GdiBase)->pLocalHeap;
|
||||
script_cache_psidx = kexPsAllocIndex();
|
||||
orphan_class_psidx = kexPsAllocIndex();
|
||||
return (BOOL)g_GdiBase;
|
||||
}
|
||||
|
||||
@ -48,7 +46,7 @@ PGDIOBJ16 GetGDIObjectPtr( HGDIOBJ hgdiobj )
|
||||
WORD wHandle = (WORD)hgdiobj;
|
||||
if ( wHandle & 1 ) return NULL; //all gdi handles end in b10 or b00, not b01
|
||||
if ( wHandle & 3 ) //64K heap
|
||||
{
|
||||
{
|
||||
PLHENTRY entry = (PLHENTRY)REBASEGDI( wHandle );
|
||||
if ( wHandle <= g_GDILH_addr || entry->bFlags == LHE_FREEHANDLE || entry->wBlock <= g_GDILH_addr )
|
||||
return NULL; //deleted or invalid handle
|
||||
@ -62,7 +60,7 @@ PGDIOBJ16 GetGDIObjectPtr( HGDIOBJ hgdiobj )
|
||||
return (PGDIOBJ16)REBASEGDI(entry->wBlock);
|
||||
}
|
||||
}
|
||||
else //high heap
|
||||
else //high heap (not moveable)
|
||||
__try
|
||||
{
|
||||
if ( wHandle < 0x80 ) return NULL; //high heap handles start with 0x80
|
||||
@ -120,36 +118,39 @@ static DWORD SwitchGDIObjectType( PGDIOBJ16 obj )
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* MAKE_EXPORT GetObjectType_fix=GetObjectType */
|
||||
DWORD WINAPI GetObjectType_fix( HGDIOBJ hgdiobj )
|
||||
{
|
||||
//GetObjectType is rewritten in order to boost it's correctness and speed:
|
||||
//constantly throwing page/segfaults is very bad on virtual machines.
|
||||
PGDIOBJ16 obj = GetGDIObjectPtr( hgdiobj );
|
||||
//constantly throwing page/segfaults is very bad on virtual machines.
|
||||
DWORD result = 0;
|
||||
if ( obj )
|
||||
if (hgdiobj)
|
||||
{
|
||||
PGDIOBJ16 obj;
|
||||
GrabWin16Lock();
|
||||
result = SwitchGDIObjectType( obj );
|
||||
obj = GetGDIObjectPtr( hgdiobj );
|
||||
if ( obj )
|
||||
result = SwitchGDIObjectType( obj );
|
||||
ReleaseWin16Lock();
|
||||
}
|
||||
else //still, can be metafile selector
|
||||
{
|
||||
WORD wHandle = (WORD)hgdiobj;
|
||||
if ( (wHandle & 6) == 6 ) //test for ldt selector
|
||||
if ( !obj ) //still, can be metafile selector
|
||||
{
|
||||
LDT_ENTRY selector;
|
||||
GetThreadSelectorEntry( GetCurrentThread(), wHandle, &selector );
|
||||
if ( selector.HighWord.Bits.Type == 3 )
|
||||
result = GetObjectType(hgdiobj); //resort to gdi32
|
||||
WORD wHandle = (WORD)hgdiobj;
|
||||
if ( (wHandle & 6) == 6 ) //test for ldt selector
|
||||
{
|
||||
LDT_ENTRY selector;
|
||||
GetThreadSelectorEntry( GetCurrentThread(), wHandle, &selector );
|
||||
if ( selector.HighWord.Bits.Type == 3 ) //read/write usermode?
|
||||
result = GetObjectType(hgdiobj); //resort to gdi32
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( !result ) SetLastError( ERROR_INVALID_HANDLE );
|
||||
if ( !result )
|
||||
SetLastError( ERROR_INVALID_HANDLE );
|
||||
return result;
|
||||
}
|
||||
|
||||
__declspec(naked)
|
||||
static inline
|
||||
WORD GetCurrentTDB()
|
||||
{
|
||||
__asm
|
||||
@ -160,98 +161,110 @@ WORD GetCurrentTDB()
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
The purpose of GdiObjects is to simulate NT GDI object rules, which
|
||||
allows deleting object handles while selected into DCs.
|
||||
|
||||
To do this, we set up an array of those handles which are checked up
|
||||
and destroyed if unselected in FIFO order when some time passes or
|
||||
array (list+map) is big enough.
|
||||
************************************************************************/
|
||||
|
||||
//those have to be under w16lock
|
||||
static inline
|
||||
GdiOrphans* GetOrphans()
|
||||
{
|
||||
return (GdiOrphans*)kexPsGetValue(orphan_class_psidx);
|
||||
}
|
||||
|
||||
static inline
|
||||
GdiOrphans* CreateOrphans()
|
||||
{
|
||||
GdiOrphans* orphans = GetOrphans();
|
||||
if (orphans == NULL)
|
||||
{
|
||||
orphans = new GdiOrphans;
|
||||
kexPsSetValue(orphan_class_psidx,orphans);
|
||||
}
|
||||
return orphans;
|
||||
}
|
||||
|
||||
/* MAKE_EXPORT DeleteObject_fix=DeleteObject */
|
||||
BOOL WINAPI DeleteObject_fix( HGDIOBJ hObject )
|
||||
{
|
||||
PGDIOBJ16 obj = GetGDIObjectPtr( hObject );
|
||||
if ( !obj || !SwitchGDIObjectType(obj) ) return FALSE;
|
||||
DWORD violated = 0;
|
||||
{
|
||||
PGDIOBJ16 obj;
|
||||
GdiOrphans* orphans = NULL;
|
||||
DWORD dwNumber = 0;
|
||||
if (!hObject) return FALSE;
|
||||
GrabWin16Lock();
|
||||
obj = GetGDIObjectPtr( hObject );
|
||||
if ( !obj || !SwitchGDIObjectType(obj) )
|
||||
{
|
||||
ReleaseWin16Lock();
|
||||
return FALSE;
|
||||
}
|
||||
//check if object is selected
|
||||
if ( obj->wOwner == GetCurrentTDB() ) //not system or foreign objects
|
||||
{
|
||||
if (obj->wType == GDI_TYPE_FONT)
|
||||
if (obj->wType == GDI_TYPE_FONT || obj->wType == GDI_TYPE_PEN )
|
||||
{
|
||||
typedef void (*DeleteUSPFontCache_fn)(HFONT hFont);
|
||||
DeleteUSPFontCache_fn DeleteUSPFontCache = (DeleteUSPFontCache_fn) kexPsGetValue(script_cache_psidx);
|
||||
if (!DeleteUSPFontCache)
|
||||
if ( obj->wRefCount >= GDI_REFCOUNT_ONCE )
|
||||
{
|
||||
DeleteUSPFontCache = (DeleteUSPFontCache_fn)kexGetProcAddress(LoadLibrary("KEXBASEN.DLL"), "DeleteUSPFontCache");
|
||||
kexPsSetValue(script_cache_psidx, DeleteUSPFontCache);
|
||||
DBGPRINTF(("Attempt to delete selected %s %p\n",
|
||||
obj->wType == GDI_TYPE_FONT ? "font":"pen",hObject));
|
||||
dwNumber = obj->dwNumber;
|
||||
}
|
||||
if (DeleteUSPFontCache)
|
||||
DeleteUSPFontCache((HFONT)hObject);
|
||||
}
|
||||
if (obj->wType == GDI_TYPE_FONT && ((PFONTOBJ16)obj)->wSelCount >= SEL_FONT_ONCE )
|
||||
if (obj->wType == GDI_TYPE_BITMAP) //can be selected into one DC
|
||||
{
|
||||
DBGPRINTF(("somebody is trying to delete selected font %p\n",hObject));
|
||||
violated = GDI_TYPE_FONT;
|
||||
}
|
||||
if (obj->wType == GDI_TYPE_BITMAP && ((PBITMAPOBJ16)obj)->wSelCount == SEL_BITMAP_ONCE )
|
||||
{
|
||||
DBGPRINTF(("somebody is trying to delete selected bitmap %p\n",hObject));
|
||||
violated = GDI_TYPE_BITMAP;
|
||||
PBITMAPOBJ16 bmpobj = (PBITMAPOBJ16)obj;
|
||||
if ( bmpobj->wSelCount )
|
||||
{
|
||||
DBGPRINTF(("Attempt to delete selected bitmap %p\n",
|
||||
hObject));
|
||||
dwNumber = obj->dwNumber;
|
||||
}
|
||||
}
|
||||
//if there is sth to record, initialize orphans class
|
||||
orphans = (dwNumber) ? CreateOrphans() : GetOrphans();
|
||||
}
|
||||
BOOL ret = DeleteObject( hObject );
|
||||
if ( violated == GDI_TYPE_FONT )
|
||||
((PFONTOBJ16)obj)->wSelCount |= SEL_FONT_DEL;
|
||||
else if ( violated == GDI_TYPE_BITMAP )
|
||||
((PBITMAPOBJ16)obj)->wSelCount |= SEL_BITMAP_DEL;
|
||||
return ret;
|
||||
ReleaseWin16Lock();
|
||||
if (orphans)
|
||||
{
|
||||
if ( dwNumber )
|
||||
orphans->RecordOrphan(hObject,dwNumber);
|
||||
else
|
||||
if ( orphans->ForgetOrphan(hObject) )
|
||||
DBGPRINTF(("WARNING: deleted handle %p is destroyed!!!\n",hObject));
|
||||
}
|
||||
return DeleteObject( hObject );
|
||||
}
|
||||
|
||||
/* MAKE_EXPORT SelectObject_fix=SelectObject */
|
||||
HGDIOBJ WINAPI SelectObject_fix( HDC hdc, HGDIOBJ hgdiobj )
|
||||
{
|
||||
//9x should do this
|
||||
//validation 9x should do
|
||||
if ( !hdc ) SetLastError(ERROR_INVALID_HANDLE);
|
||||
if ( !hdc || !hgdiobj ) return NULL;
|
||||
HGDIOBJ ret;
|
||||
ret = SelectObject( hdc, hgdiobj );
|
||||
PGDIOBJ16 obj = GetGDIObjectPtr( ret );
|
||||
if ( obj && obj->wOwner )
|
||||
{
|
||||
if ( obj->wType == GDI_TYPE_FONT && ((PFONTOBJ16)obj)->wSelCount == SEL_FONT_DEL )
|
||||
{
|
||||
DBGPRINTF(("deleting font %p on unselecting\n",ret));
|
||||
DeleteObject(ret);
|
||||
}
|
||||
if ( obj->wType == GDI_TYPE_BITMAP && ((PBITMAPOBJ16)obj)->wSelCount == SEL_BITMAP_DEL )
|
||||
{
|
||||
((PBITMAPOBJ16)obj)->wSelCount = 0;
|
||||
DBGPRINTF(("deleting bitmap %p on unselecting\n",ret));
|
||||
DeleteObject(ret);
|
||||
}
|
||||
//if object was deleted, don't let it be reselected
|
||||
GrabWin16Lock();
|
||||
PGDIOBJ16 obj = GetGDIObjectPtr( hgdiobj );
|
||||
GdiOrphans* orphans = NULL;
|
||||
DWORD dwNumber;
|
||||
if ( obj && obj->wOwner == GetCurrentTDB() )
|
||||
{
|
||||
orphans = GetOrphans();
|
||||
dwNumber = obj->dwNumber;
|
||||
}
|
||||
return ret;
|
||||
ReleaseWin16Lock();
|
||||
if ( orphans && orphans->IsOrphan(hgdiobj, dwNumber) )
|
||||
{
|
||||
DBGPRINTF(("WARNING: Attempt to select deleted handle %p\n",hgdiobj));
|
||||
return NULL;
|
||||
}
|
||||
return SelectObject( hdc, hgdiobj );
|
||||
}
|
||||
|
||||
/* MAKE_EXPORT DeleteDC_fix=DeleteDC */
|
||||
BOOL WINAPI DeleteDC_fix( HDC hdc )
|
||||
{
|
||||
BOOL ret;
|
||||
PGDIOBJ16 obj = GetGDIObjectPtr( hdc );
|
||||
if ( !obj || !SwitchGDIObjectType(obj) ) return FALSE;
|
||||
HGDIOBJ fnt = GetCurrentObject(hdc,OBJ_FONT);
|
||||
HGDIOBJ bmp = GetCurrentObject(hdc,OBJ_BITMAP);
|
||||
ret = DeleteDC(hdc);
|
||||
if (ret)
|
||||
{
|
||||
PFONTOBJ16 fntobj = (PFONTOBJ16)GetGDIObjectPtr(fnt);
|
||||
PBITMAPOBJ16 bitmapobj = (PBITMAPOBJ16)GetGDIObjectPtr(bmp);
|
||||
if (fntobj && fntobj->wOwner && fntobj->wType == GDI_TYPE_FONT && fntobj->wSelCount == SEL_FONT_DEL)
|
||||
{
|
||||
DBGPRINTF(("deleting font %p on dc cleanup\n",fnt));
|
||||
DeleteObject(fnt);
|
||||
}
|
||||
if (bitmapobj && bitmapobj->header.wOwner && bitmapobj->header.wType == GDI_TYPE_BITMAP && bitmapobj->wSelCount == SEL_BITMAP_DEL)
|
||||
{
|
||||
bitmapobj->wSelCount = 0;
|
||||
DBGPRINTF(("deleting bitmap %p on dc cleanup\n",bmp));
|
||||
DeleteObject(bmp);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* MAKE_EXPORT CreateDIBSection_fix=CreateDIBSection */
|
||||
HBITMAP WINAPI CreateDIBSection_fix(
|
||||
@ -265,5 +278,19 @@ HBITMAP WINAPI CreateDIBSection_fix(
|
||||
{
|
||||
if (pbmi && pbmi->bmiHeader.biSize == sizeof(BITMAPINFO)) //9x does not forgive
|
||||
pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); //9x does not forget
|
||||
return CreateDIBSection(hdc,pbmi,iUsage,ppvBits,hSection,dwOffset);
|
||||
HBITMAP ret = CreateDIBSection(hdc,pbmi,iUsage,ppvBits,hSection,dwOffset);
|
||||
GdiOrphans* orphans = GetOrphans();
|
||||
if (orphans)
|
||||
orphans->RunCleanup();
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* MAKE_EXPORT CreateFontIndirectA_fix=CreateFontIndirectA */
|
||||
HFONT WINAPI CreateFontIndirectA_fix( CONST LOGFONT* lplf )
|
||||
{
|
||||
HFONT ret = CreateFontIndirectA(lplf);
|
||||
GdiOrphans* orphans = GetOrphans();
|
||||
if (orphans)
|
||||
orphans->RunCleanup();
|
||||
return ret;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* KernelEx
|
||||
*
|
||||
* Copyright (C) 2009, Tihiy
|
||||
* Copyright (C) 2009-2010, Tihiy
|
||||
* This file is part of KernelEx source code.
|
||||
*
|
||||
* KernelEx is free software; you can redistribute it and/or modify
|
||||
@ -26,6 +26,9 @@
|
||||
void GrabWin16Lock();
|
||||
void ReleaseWin16Lock();
|
||||
|
||||
#define GDIHEAP32BASE 0x10000
|
||||
#define GDIHEAP32TOP 0x20000
|
||||
|
||||
#define LHE_DISCARDED 0x40
|
||||
#define LHE_MUTATED 0x80
|
||||
#define LHE_FREEHANDLE 0xFF
|
||||
@ -43,10 +46,7 @@ void ReleaseWin16Lock();
|
||||
#define GDI_TYPE_METADC 0x4F51
|
||||
#define GDI_TYPE_ENHMETA 0x4F52
|
||||
|
||||
#define SEL_FONT_ONCE 0x4
|
||||
#define SEL_FONT_DEL 0x2
|
||||
#define SEL_BITMAP_ONCE 0x01
|
||||
#define SEL_BITMAP_DEL 0x10
|
||||
#define GDI_REFCOUNT_ONCE 0x4
|
||||
|
||||
#define ResetMapMode( hdc ) SetMapMode( hdc, GetMapMode(hdc) )
|
||||
|
||||
@ -70,6 +70,17 @@ typedef struct
|
||||
BYTE bLocks;
|
||||
} LHENTRY, *PLHENTRY;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
WORD wZero; //+0 zero
|
||||
WORD wType; //+2 object type | flags
|
||||
DWORD dwNumber; //+4 number++
|
||||
WORD wReserved; //+8 sth specific
|
||||
WORD wRefCount; //+A number of DCs selected into * GDI_REFCOUNT_ONCE
|
||||
WORD wOwner; //+C HTASK (TDB16) of process or library owning
|
||||
} GDIOBJ16, *PGDIOBJ16;
|
||||
|
||||
//bitmaps and DCs have special headers
|
||||
typedef struct
|
||||
{
|
||||
WORD wZero; //+0
|
||||
@ -77,32 +88,17 @@ typedef struct
|
||||
DWORD dwNumber; //+4
|
||||
DWORD dwSpecific; //+8
|
||||
WORD wOwner; //+C
|
||||
} GDIOBJ16, *PGDIOBJ16;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GDIOBJ16 header;
|
||||
WORD wGlobalBitmap; //+14
|
||||
WORD wSelCount; //+16
|
||||
WORD wHDC; //+18
|
||||
WORD wGlobalBitmapInfo; //+20
|
||||
DWORD dwReservedShit; //+22
|
||||
WORD wBitmapStuff; //+26
|
||||
WORD wDeviceStuff; //+28
|
||||
WORD wBitmapType; //+30
|
||||
WORD wLogColorSpace; //+32
|
||||
WORD wGlobalBitmap; //+E
|
||||
WORD wSelCount; //+10
|
||||
WORD wHDC; //+12
|
||||
WORD wGlobalBitmapInfo; //+14
|
||||
DWORD dwReservedShit; //+16
|
||||
WORD wBitmapStuff; //+1A
|
||||
WORD wDeviceStuff; //+1C
|
||||
WORD wBitmapType; //+1E
|
||||
WORD wLogColorSpace; //+20
|
||||
} BITMAPOBJ16, *PBITMAPOBJ16;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
WORD wZero; //+0
|
||||
WORD wType; //+2
|
||||
DWORD dwStuff; //+4
|
||||
WORD wReserved; //+8 (not used?)
|
||||
WORD wSelCount; //+A
|
||||
WORD wOwner; //+C
|
||||
} FONTOBJ16, *PFONTOBJ16;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
WORD wZero; //+0
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* KernelEx
|
||||
* Copyright (C) 2008, Xeno86
|
||||
* Copyright (C) 2010, Xeno86
|
||||
*
|
||||
* This file is part of KernelEx source code.
|
||||
*
|
||||
@ -21,38 +21,24 @@
|
||||
|
||||
#include "common.h"
|
||||
|
||||
int acp_mcs;
|
||||
|
||||
static int GetMaxCharSize(UINT CodePage)
|
||||
/* MAKE_EXPORT GetTextExtentPoint32A_fix=GetTextExtentPoint32A */
|
||||
BOOL WINAPI GetTextExtentPoint32A_fix(HDC hdc, LPCSTR str, int count, LPSIZE size)
|
||||
{
|
||||
CPINFO cpi;
|
||||
if (!GetCPInfo(CodePage, &cpi))
|
||||
return 2;
|
||||
return cpi.MaxCharSize;
|
||||
}
|
||||
|
||||
BOOL common_init(void)
|
||||
{
|
||||
acp_mcs = GetMaxCharSize(CP_ACP);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
char* file_fixWprefix(char* in)
|
||||
{
|
||||
if (*(int *)in == 0x5c3f5c5c) //if (!strncmp(in, "\\?\", 4))
|
||||
if (count < 0)
|
||||
{
|
||||
in += 4;
|
||||
if (*(int *)in == 0x5c434e55) //if (!strncmp(in, "UNC\", 4))
|
||||
{
|
||||
in += 2;
|
||||
*in = '\\';
|
||||
}
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
return in;
|
||||
return GetTextExtentPoint32A(hdc, str, count, size);
|
||||
}
|
||||
|
||||
void fatal_error(const char* msg)
|
||||
/* MAKE_EXPORT GetTextExtentPoint32W_fix=GetTextExtentPoint32W */
|
||||
BOOL WINAPI GetTextExtentPoint32W_fix(HDC hdc, LPCWSTR str, int count, LPSIZE size)
|
||||
{
|
||||
MessageBox(NULL, msg, "KernelEx error", MB_OK | MB_ICONERROR);
|
||||
ExitProcess(1);
|
||||
if (count < 0)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
return GetTextExtentPoint32W(hdc, str, count, size);
|
||||
}
|
155
apilibs/kexbases/Gdi32/Orhpans.cpp
Executable file
155
apilibs/kexbases/Gdi32/Orhpans.cpp
Executable file
@ -0,0 +1,155 @@
|
||||
/*
|
||||
* KernelEx
|
||||
*
|
||||
* Copyright (C) 2010, Tihiy
|
||||
*
|
||||
* This file is part of KernelEx source code.
|
||||
*
|
||||
* KernelEx is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published
|
||||
* by the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* KernelEx is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Make; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include "Orhpans.h"
|
||||
#include "GdiObjects.h"
|
||||
#include "kexcoresdk.h"
|
||||
|
||||
|
||||
GdiOrphans::GdiOrphans()
|
||||
{
|
||||
InitializeCriticalSection(&cs);
|
||||
dwTickLastRecord = GetTickCount();
|
||||
}
|
||||
|
||||
GdiOrphans::~GdiOrphans()
|
||||
{
|
||||
DeleteCriticalSection(&cs);
|
||||
}
|
||||
|
||||
//returns TRUE if handle is found and it's not hijacked
|
||||
BOOL GdiOrphans::IsOrphan(HGDIOBJ hObject, DWORD dwNumber)
|
||||
{
|
||||
EnterCriticalSection(&cs);
|
||||
BOOL ret;
|
||||
map<HGDIOBJ,PGDIORPHAN>::iterator it = handle_map.find(hObject);
|
||||
if (it == handle_map.end())
|
||||
ret = FALSE;
|
||||
else
|
||||
ret = (it->second->dwNumber == dwNumber) ? TRUE : FALSE;
|
||||
LeaveCriticalSection(&cs);
|
||||
return ret;
|
||||
}
|
||||
|
||||
//removes handle, returns TRUE if it was there
|
||||
BOOL GdiOrphans::ForgetOrphan(HGDIOBJ hObject)
|
||||
{
|
||||
EnterCriticalSection(&cs);
|
||||
BOOL ret;
|
||||
map<HGDIOBJ,PGDIORPHAN>::iterator it = handle_map.find(hObject);
|
||||
if (it == handle_map.end())
|
||||
ret = FALSE;
|
||||
else
|
||||
{
|
||||
delete it->second;
|
||||
handle_list.remove(it->second);
|
||||
handle_map.erase(it);
|
||||
ret = TRUE;
|
||||
}
|
||||
LeaveCriticalSection(&cs);
|
||||
return ret;
|
||||
}
|
||||
|
||||
//adds handle into our records if it's not already there
|
||||
void GdiOrphans::RecordOrphan(HGDIOBJ hObject, DWORD dwNumber)
|
||||
{
|
||||
EnterCriticalSection(&cs);
|
||||
map<HGDIOBJ,PGDIORPHAN>::iterator it = handle_map.find(hObject);
|
||||
if (it == handle_map.end()) //not found
|
||||
{
|
||||
PGDIORPHAN neworphan = new GDIORPHAN;
|
||||
if (neworphan)
|
||||
{
|
||||
neworphan->hObject = hObject;
|
||||
neworphan->dwNumber = dwNumber;
|
||||
handle_map.insert(pair<HGDIOBJ,PGDIORPHAN>(hObject,neworphan));
|
||||
handle_list.push_back(neworphan);
|
||||
if (handle_map.size() >= MAXGDIORPHANS)
|
||||
{
|
||||
DBGPRINTF(("Too many handles (%d), cleaning up!\n",handle_map.size()));
|
||||
CleanupOrphan();
|
||||
}
|
||||
}
|
||||
}
|
||||
else //found
|
||||
{
|
||||
it->second->dwNumber = dwNumber;
|
||||
}
|
||||
LeaveCriticalSection(&cs);
|
||||
dwTickLastRecord = GetTickCount();
|
||||
}
|
||||
|
||||
//finds one handle which is hijacked or unselected and removes it
|
||||
void GdiOrphans::CleanupOrphan()
|
||||
{
|
||||
int cleanup = 0;
|
||||
list<PGDIORPHAN>::iterator it;
|
||||
for (it = handle_list.begin(); it != handle_list.end(); it++)
|
||||
{
|
||||
GrabWin16Lock();
|
||||
PGDIORPHAN orphan = *it;
|
||||
PGDIOBJ16 obj = GetGDIObjectPtr(orphan->hObject);
|
||||
//handle somehow got destroyed without us knowing?
|
||||
if (!obj || obj->dwNumber != orphan->dwNumber)
|
||||
{
|
||||
DBGPRINTF(("WARNING: Handle %p invalidated!!!",orphan->hObject));
|
||||
cleanup = 1;
|
||||
}
|
||||
else //was object unselected?
|
||||
{
|
||||
if ( (obj->wType == GDI_TYPE_FONT || obj->wType == GDI_TYPE_PEN)
|
||||
&& obj->wRefCount < GDI_REFCOUNT_ONCE )
|
||||
{
|
||||
DBGPRINTF(("Cleaning up unselected deleted %s %p\n",
|
||||
obj->wType == GDI_TYPE_FONT ? "font":"pen",orphan->hObject));
|
||||
cleanup = 2;
|
||||
}
|
||||
if ( obj->wType == GDI_TYPE_BITMAP && ((PBITMAPOBJ16)obj)->wSelCount == 0 )
|
||||
{
|
||||
DBGPRINTF(("Cleaning up unselected deleted bitmap %p\n",orphan->hObject));
|
||||
cleanup = 2;
|
||||
}
|
||||
}
|
||||
ReleaseWin16Lock();
|
||||
if (cleanup)
|
||||
{
|
||||
if (cleanup == 2)
|
||||
DeleteObject(orphan->hObject);
|
||||
handle_list.erase(it);
|
||||
handle_map.erase(orphan->hObject);
|
||||
delete orphan;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//public version of cleanup
|
||||
void GdiOrphans::RunCleanup()
|
||||
{
|
||||
if (GetTickCount() - dwTickLastRecord < ORPHANTTL) return;
|
||||
EnterCriticalSection(&cs);
|
||||
CleanupOrphan();
|
||||
LeaveCriticalSection(&cs);
|
||||
//don't run cleanup too often either
|
||||
dwTickLastRecord = GetTickCount();
|
||||
}
|
60
apilibs/kexbases/Gdi32/Orhpans.h
Executable file
60
apilibs/kexbases/Gdi32/Orhpans.h
Executable file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* KernelEx
|
||||
*
|
||||
* Copyright (C) 2010, Tihiy
|
||||
*
|
||||
* This file is part of KernelEx source code.
|
||||
*
|
||||
* KernelEx is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published
|
||||
* by the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* KernelEx is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Make; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __ORPHANS_H
|
||||
#define __ORPHANS_H
|
||||
|
||||
#pragma warning(disable:4530) //we don't do exception handling
|
||||
#pragma warning(disable:4786) //don't care about this either
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
#define MAXGDIORPHANS 6 //threshold size which triggers cleanup
|
||||
#define ORPHANTTL 2000 //msecs to try give for objects to live
|
||||
|
||||
//gdi object handle and its gdi number for consistency check
|
||||
typedef struct _GDIORPHAN
|
||||
{
|
||||
HGDIOBJ hObject;
|
||||
DWORD dwNumber;
|
||||
} GDIORPHAN, *PGDIORPHAN;
|
||||
|
||||
using namespace std;
|
||||
|
||||
class GdiOrphans
|
||||
{
|
||||
public:
|
||||
GdiOrphans();
|
||||
~GdiOrphans();
|
||||
void RecordOrphan(HGDIOBJ hObject, DWORD dwNumber);
|
||||
BOOL IsOrphan(HGDIOBJ hObject, DWORD dwNumber);
|
||||
BOOL ForgetOrphan(HGDIOBJ hObject);
|
||||
void RunCleanup();
|
||||
private:
|
||||
map<HGDIOBJ,PGDIORPHAN> handle_map;
|
||||
list<PGDIORPHAN> handle_list;
|
||||
CRITICAL_SECTION cs;
|
||||
void CleanupOrphan();
|
||||
DWORD dwTickLastRecord;
|
||||
};
|
||||
|
||||
#endif
|
@ -6,7 +6,7 @@
|
||||
* Copyright 2002,2003 Shachar Shemesh
|
||||
* Copyright 2003 CodeWeavers Inc. (Ulrich Czekalla)
|
||||
*
|
||||
* Copyright (C) 2008, Tihiy
|
||||
* Copyright (C) 2008, 2010, Tihiy
|
||||
*
|
||||
* This file is part of KernelEx source code.
|
||||
*
|
||||
@ -110,6 +110,7 @@ BOOL WINAPI SetWorldTransform_NT(
|
||||
CONST XFORM *lpXform // transformation data
|
||||
)
|
||||
{
|
||||
GrabWin16Lock();
|
||||
PDCOBJ dcobj = GetDCObj(hdc);
|
||||
WORD savemapmode;
|
||||
int wx;
|
||||
@ -119,6 +120,7 @@ BOOL WINAPI SetWorldTransform_NT(
|
||||
if ( !dcobj || !lpXform || !almostzero(lpXform->eM12) || !almostzero(lpXform->eM21)
|
||||
|| almostzero(lpXform->eM11) || almostzero(lpXform->eM22) )
|
||||
{
|
||||
ReleaseWin16Lock();
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE; //no rotating for you
|
||||
}
|
||||
@ -132,6 +134,7 @@ BOOL WINAPI SetWorldTransform_NT(
|
||||
SetViewportOrgEx(hdc,(int)lpXform->eDx,(int)lpXform->eDy,NULL);
|
||||
//set it back
|
||||
dcobj->mapmode = savemapmode;
|
||||
ReleaseWin16Lock();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -156,17 +159,24 @@ BOOL WINAPI GetTextMetricsA_NT(
|
||||
LPTEXTMETRIC lptm // text metrics
|
||||
)
|
||||
{
|
||||
GrabWin16Lock();
|
||||
PDCOBJ dcobj = GetDCObj(hdc);
|
||||
int saved = 0;
|
||||
BOOL retval;
|
||||
if ( !dcobj ) return FALSE;
|
||||
if ( !dcobj )
|
||||
{
|
||||
ReleaseWin16Lock();
|
||||
return FALSE;
|
||||
}
|
||||
if ( dcobj->ViewportExtX != 1 || dcobj->ViewportExtY != 1 || dcobj->WindowExtX != 1 || dcobj->WindowExtY != 1 )
|
||||
{
|
||||
saved = SaveDC(hdc);
|
||||
ResetMapMode(hdc);
|
||||
}
|
||||
retval = GetTextMetricsA(hdc,lptm);
|
||||
if ( saved ) RestoreDC(hdc,-1);
|
||||
if ( saved )
|
||||
RestoreDC(hdc,-1);
|
||||
ReleaseWin16Lock();
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -286,7 +296,6 @@ BOOL WINAPI ExtTextOutW_new(
|
||||
{
|
||||
BOOL result;
|
||||
int* buffer = NULL;
|
||||
PDCOBJ dcobj = GetDCObj( hdc );
|
||||
WORD savemapmode = 0;
|
||||
|
||||
if ( HIWORD(lpString) )
|
||||
@ -309,6 +318,9 @@ BOOL WINAPI ExtTextOutW_new(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GrabWin16Lock();
|
||||
PDCOBJ dcobj = GetDCObj( hdc );
|
||||
if ( dcobj && dcobj->mapmode == MM_TEXT &&
|
||||
( dcobj->ViewportExtX!=1 || dcobj->ViewportExtY!=1
|
||||
|| dcobj->WindowExtX!=1 || dcobj->WindowExtY!=1) )
|
||||
@ -319,6 +331,7 @@ BOOL WINAPI ExtTextOutW_new(
|
||||
result = ExtTextOutW(hdc,X,Y,fuOptions,lprc,lpString,cbCount,lpDx);
|
||||
if ( savemapmode )
|
||||
dcobj->mapmode = savemapmode;
|
||||
ReleaseWin16Lock();
|
||||
|
||||
if ( buffer && cbCount>128 )
|
||||
HeapFree(GetProcessHeap(),0,buffer);
|
||||
|
@ -42,7 +42,7 @@ static const apilib_named_api gdi32_named_apis[] =
|
||||
DECL_API("AddFontResourceExW", AddFontResourceExW_new),
|
||||
DECL_API("AddFontResourceW", AddFontResourceW_new),
|
||||
DECL_API("CreateDIBSection", CreateDIBSection_fix),
|
||||
DECL_API("DeleteDC", DeleteDC_fix),
|
||||
DECL_API("CreateFontIndirectA", CreateFontIndirectA_fix),
|
||||
DECL_API("DeleteObject", DeleteObject_fix),
|
||||
DECL_API("EnumFontFamiliesExA", EnumFontFamiliesExA_new),
|
||||
DECL_API("EnumFontFamiliesExW", EnumFontFamiliesExW_new),
|
||||
@ -59,6 +59,8 @@ static const apilib_named_api gdi32_named_apis[] =
|
||||
DECL_API("GetObjectType", GetObjectType_fix),
|
||||
DECL_API("GetObjectW", GetObjectW_new),
|
||||
DECL_API("GetRandomRgn", GetRandomRgn_NT),
|
||||
DECL_API("GetTextExtentPoint32A", GetTextExtentPoint32A_fix),
|
||||
DECL_API("GetTextExtentPoint32W", GetTextExtentPoint32W_fix),
|
||||
DECL_API("GetTextMetricsA", GetTextMetricsA_NT),
|
||||
DECL_API("GetWorldTransform", GetWorldTransform_NT),
|
||||
DECL_API("ModifyWorldTransform", ModifyWorldTransform_NT),
|
||||
|
@ -35,9 +35,11 @@ BOOL WINAPI RemoveFontMemResourceEx_stub(HANDLE fh);
|
||||
DWORD WINAPI GetObjectType_fix(HGDIOBJ hgdiobj);
|
||||
BOOL WINAPI DeleteObject_fix(HGDIOBJ hObject);
|
||||
HGDIOBJ WINAPI SelectObject_fix(HDC hdc, HGDIOBJ hgdiobj);
|
||||
BOOL WINAPI DeleteDC_fix(HDC hdc);
|
||||
HBITMAP WINAPI CreateDIBSection_fix(HDC hdc, BITMAPINFO *pbmi, UINT iUsage, VOID **ppvBits, HANDLE hSection, DWORD dwOffset);
|
||||
HFONT WINAPI CreateFontIndirectA_fix(CONST LOGFONT* lplf);
|
||||
DWORD WINAPI GetGlyphOutlineA_fix(HDC hdc, UINT uChar, UINT uFormat, LPGLYPHMETRICS lpgm, DWORD cbBuffer, LPVOID lpvBuffer, CONST MAT2 *lpmat2);
|
||||
BOOL WINAPI GetTextExtentPoint32A_fix(HDC hdc, LPCSTR str, int count, LPSIZE size);
|
||||
BOOL WINAPI GetTextExtentPoint32W_fix(HDC hdc, LPCWSTR str, int count, LPSIZE size);
|
||||
DWORD WINAPI GetFontUnicodeRanges_new(HDC hdc, LPGLYPHSET lpgs);
|
||||
int WINAPI SetGraphicsMode_NT(HDC hdc, int iMode);
|
||||
BOOL WINAPI SetWorldTransform_9x(HDC hdc, CONST XFORM *lpXform);
|
||||
|
@ -229,7 +229,10 @@ int WINAPI GetObjectW_new(
|
||||
LOGFONTW fontW = {0};
|
||||
if (!GetObjectA(hgdiobj,sizeof(LOGFONTA),&fontA)) return 0; //err not font
|
||||
memcpy(&fontW,&fontA,FIELD_OFFSET(LOGFONTA,lfFaceName));
|
||||
MultiByteToWideChar(CP_ACP,0,fontA.lfFaceName,-1,fontW.lfFaceName,LF_FACESIZE);
|
||||
if (hgdiobj == GetStockObject(DEFAULT_GUI_FONT)) //unicode apps get Tahoma
|
||||
lstrcpyW(fontW.lfFaceName,L"Tahoma");
|
||||
else
|
||||
MultiByteToWideChar(CP_ACP,0,fontA.lfFaceName,-1,fontW.lfFaceName,LF_FACESIZE);
|
||||
memcpy(lpvObject,&fontW,cbBuffer);
|
||||
return cbBuffer;
|
||||
}
|
||||
|
69
apilibs/kexbases/Kernel32/CriticalSection_fix.c
Executable file
69
apilibs/kexbases/Kernel32/CriticalSection_fix.c
Executable file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* KernelEx
|
||||
*
|
||||
* Copyright (C) 2010, Xeno86
|
||||
* Copyright (C) 2008, Tihiy
|
||||
*
|
||||
* This file is part of KernelEx source code.
|
||||
*
|
||||
* KernelEx is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published
|
||||
* by the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* KernelEx is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Make; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include "kstructs.h"
|
||||
|
||||
/* MAKE_EXPORT DeleteCriticalSection_fix=DeleteCriticalSection */
|
||||
void WINAPI DeleteCriticalSection_fix(PCRITICAL_SECTION lpCriticalSection)
|
||||
{
|
||||
//make DeleteCriticalSection not fail on deleted section
|
||||
byte* deleted = (byte*) lpCriticalSection;
|
||||
if (*deleted != 0) DeleteCriticalSection(lpCriticalSection);
|
||||
}
|
||||
|
||||
/*
|
||||
* Terminate process if EnterCriticalSection is called on orphaned CS
|
||||
* in DLL_PROCESS_DETACH - Vista behaviour.
|
||||
* refer: http://blogs.msdn.com/b/oldnewthing/archive/2010/01/22/9951750.aspx
|
||||
*/
|
||||
|
||||
static void orphaned_cs_handler();
|
||||
|
||||
__declspec(naked)
|
||||
/* MAKE_EXPORT EnterCriticalSection_fix=EnterCriticalSection */
|
||||
void WINAPI EnterCriticalSection_fix(LPCRITICAL_SECTION lpCriticalSection)
|
||||
{
|
||||
__asm {
|
||||
mov eax, [esp+4]
|
||||
cmp byte ptr [eax], WIN98_K32OBJ_CRITICAL_SECTION
|
||||
jnz __error
|
||||
jmp dword ptr [EnterCriticalSection]
|
||||
__error:
|
||||
jmp orphaned_cs_handler
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void orphaned_cs_handler()
|
||||
{
|
||||
PDB98* pdb = get_pdb();
|
||||
DWORD want_flags = fSendDllNotifications | fTerminating;
|
||||
//if process is in dll detach - terminate silently
|
||||
if ((pdb->Flags & want_flags) == want_flags)
|
||||
{
|
||||
SetErrorMode(SEM_NOGPFAULTERRORBOX | SEM_FAILCRITICALERRORS);
|
||||
}
|
||||
//throw exception
|
||||
RaiseException(EXCEPTION_ACCESS_VIOLATION, 0, 0, NULL);
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* KernelEx
|
||||
* Copyright (C) 2010, Tihiy
|
||||
*
|
||||
* Copyright (C) 2008, Tihiy
|
||||
* This file is part of KernelEx source code.
|
||||
*
|
||||
* KernelEx is free software; you can redistribute it and/or modify
|
||||
@ -18,13 +18,26 @@
|
||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
#include "kstructs.h"
|
||||
|
||||
/* MAKE_EXPORT DeleteCriticalSection_new=DeleteCriticalSection */
|
||||
void WINAPI DeleteCriticalSection_new(PCRITICAL_SECTION lpCriticalSection)
|
||||
/* MAKE_EXPORT ExitProcess_fix=ExitProcess */
|
||||
VOID WINAPI ExitProcess_fix( UINT uExitCode )
|
||||
{
|
||||
//make DeleteCriticalSection not fail on deleted section
|
||||
byte* deleted = (byte*) lpCriticalSection;
|
||||
if (*deleted != 0) DeleteCriticalSection(lpCriticalSection);
|
||||
PDB98* pdb = get_pdb();
|
||||
|
||||
//process is already terminating. we would badly crash
|
||||
if (pdb->Flags & fTerminating)
|
||||
{
|
||||
//so instead silently fail
|
||||
SetErrorMode(SEM_NOGPFAULTERRORBOX | SEM_FAILCRITICALERRORS);
|
||||
RaiseException(EXCEPTION_ACCESS_VIOLATION, 0, 0, NULL);
|
||||
}
|
||||
|
||||
//set calling thread priority to the lowest possible. this way
|
||||
//we greatly improve chance for thread which calls ExitProcess
|
||||
//to finish latest and call dll process detach like NT
|
||||
SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_IDLE);
|
||||
ExitProcess(uExitCode);
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* KernelEx
|
||||
* Copyright (C) 2010, Tihiy
|
||||
* Copyright (C) 2008, Xeno86
|
||||
*
|
||||
* This file is part of KernelEx source code.
|
||||
@ -20,6 +21,73 @@
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include "kexcoresdk.h"
|
||||
#include "kstructs.h"
|
||||
#include "k32ord.h"
|
||||
|
||||
#define RELTOABS(x) ( (DWORD)(x) + *(DWORD*)(x) + 4 )
|
||||
#define MAPHANDLE_MAPPED 0x1000
|
||||
|
||||
/*
|
||||
* A bit of mapping file 9x rules:
|
||||
* copy-on-write access is possible to file mappings created with
|
||||
* PAGE_WRITECOPY. Note that it makes sense only to real files.
|
||||
* If you CreateFileMapping on INVALID_HANDLE_VALUE with PAGE_WRITECOPY
|
||||
* you will get mapping handle which can be only mapped with FILE_MAP_READ
|
||||
* PAGE_READONLY can be mapped only with FILE_MAP_READ, end of story
|
||||
* PAGE_READWRITE can be mapped with any FILE_MAP_READ or FILE_MAP_WRITE
|
||||
* but not FILE_MAP_COPY; however FILE_MAP_ALL_ACCESS is fine
|
||||
* kernel checks exactly for it, other masks with FILE_MAP_COPY will fail.
|
||||
*
|
||||
* Office 2003 workaround is hack for specific access mask which breaks
|
||||
* that FILE_MAP_COPY rule
|
||||
*/
|
||||
|
||||
#define FILE_MAP_OFFICE2003 (SECTION_QUERY | SECTION_MAP_WRITE | \
|
||||
SECTION_MAP_READ | SECTION_MAP_EXECUTE | \
|
||||
SECTION_EXTEND_SIZE | READ_CONTROL)
|
||||
|
||||
//MapHandle: maps kernel handle to object
|
||||
static PVOID MapHandle(HANDLE hObject, DWORD dwFlags, DWORD dwReserved)
|
||||
{
|
||||
typedef PDWORD (WINAPI *MapHandle_t)(HANDLE,DWORD,DWORD);
|
||||
static MapHandle_t KernelMapHandle;
|
||||
if (!KernelMapHandle)
|
||||
KernelMapHandle = (MapHandle_t)RELTOABS((DWORD)kexGetProcAddress(
|
||||
GetModuleHandle("KERNEL32.DLL"),"OpenVxDHandle")+0xC);
|
||||
return KernelMapHandle(hObject,dwFlags,dwReserved);
|
||||
}
|
||||
|
||||
static LPVOID GetMapViewAddress(HANDLE hFileMapping)
|
||||
{
|
||||
PVOID ret = (PVOID)-1;
|
||||
PFILEMAPPING mapobj;
|
||||
static CRITICAL_SECTION* k32lock;
|
||||
if (!k32lock)
|
||||
k32lock = (CRITICAL_SECTION*) kexGetK32Lock();
|
||||
_EnterSysLevel(k32lock);
|
||||
mapobj = (PFILEMAPPING)MapHandle(hFileMapping,MAPHANDLE_MAPPED,0);
|
||||
if (mapobj && mapobj->type == WIN98_K32OBJ_MEM_MAPPED_FILE)
|
||||
ret = mapobj->mapaddr;
|
||||
_LeaveSysLevel(k32lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static DWORD FindSharedMem64K(DWORD StartAddress)
|
||||
{
|
||||
MEMORY_BASIC_INFORMATION mbi;
|
||||
DWORD TryAddress = StartAddress;
|
||||
while (true)
|
||||
{
|
||||
if (TryAddress & 0x0FFFF) //64K align
|
||||
TryAddress = (TryAddress & 0xFFFF0000) + 0x10000;
|
||||
if ( !VirtualQuery((PVOID)TryAddress,&mbi,sizeof(mbi)) ) return NULL;
|
||||
if (mbi.State == MEM_FREE)
|
||||
return TryAddress;
|
||||
TryAddress = (DWORD)mbi.BaseAddress + (DWORD)mbi.RegionSize;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* MAKE_EXPORT MapViewOfFileEx_new=MapViewOfFileEx */
|
||||
LPVOID WINAPI MapViewOfFileEx_new(
|
||||
@ -39,6 +107,57 @@ LPVOID WINAPI MapViewOfFileEx_new(
|
||||
{
|
||||
lpBaseAddress = 0;
|
||||
}
|
||||
return MapViewOfFileEx(hFileMappingObject, dwDesiredAccess, dwFileOffsetHigh,
|
||||
dwFileOffsetLow, dwNumberOfBytesToMap, lpBaseAddress);
|
||||
|
||||
LPVOID ret = NULL;
|
||||
if ( dwDesiredAccess == FILE_MAP_OFFICE2003 )
|
||||
{
|
||||
DBGPRINTF(("KEX: Using 64K align workaround on memmap handle %p\n",
|
||||
hFileMappingObject));
|
||||
//was it already mapped?
|
||||
LPVOID oldmapaddr = GetMapViewAddress(hFileMappingObject);
|
||||
if (oldmapaddr == (LPVOID)-1)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_HANDLE);
|
||||
return NULL;
|
||||
}
|
||||
if (oldmapaddr) //if it was, try that address first
|
||||
ret = MapViewOfFileEx(hFileMappingObject,FILE_MAP_ALL_ACCESS,
|
||||
dwFileOffsetHigh,dwFileOffsetLow,dwNumberOfBytesToMap,oldmapaddr);
|
||||
//search shared memory piece, skipping 64K to not deadloop
|
||||
DWORD mem64K = 0x81000000;
|
||||
while (!ret)
|
||||
{
|
||||
mem64K = FindSharedMem64K(mem64K + 0x10000);
|
||||
if (!mem64K)
|
||||
{
|
||||
DBGPRINTF(("KEX: Failed to find memory for mapping handle %p!",
|
||||
hFileMappingObject));
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
DWORD gle = GetLastError();
|
||||
SetLastError(0);
|
||||
ret = MapViewOfFileEx(hFileMappingObject,FILE_MAP_ALL_ACCESS,dwFileOffsetHigh,
|
||||
dwFileOffsetLow,dwNumberOfBytesToMap,(LPVOID)mem64K);
|
||||
if ( GetLastError() == ERROR_INVALID_PARAMETER ) //not according to plan
|
||||
return NULL;
|
||||
else
|
||||
SetLastError(gle);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = MapViewOfFileEx(hFileMappingObject, dwDesiredAccess, dwFileOffsetHigh,
|
||||
dwFileOffsetLow, dwNumberOfBytesToMap, lpBaseAddress);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* MAKE_EXPORT MapViewOfFile_new=MapViewOfFile */
|
||||
LPVOID WINAPI MapViewOfFile_new( HANDLE hFileMappingObject, DWORD dwDesiredAccess,
|
||||
DWORD dwFileOffsetHigh, DWORD dwFileOffsetLow, SIZE_T dwNumberOfBytesToMap )
|
||||
{
|
||||
return MapViewOfFileEx_new(hFileMappingObject, dwDesiredAccess,
|
||||
dwFileOffsetHigh, dwFileOffsetLow, dwNumberOfBytesToMap, NULL);
|
||||
}
|
||||
|
@ -67,12 +67,14 @@ static const apilib_named_api kernel32_named_apis[] =
|
||||
DECL_API("DecodePointer", XorPointer),
|
||||
DECL_API("DecodeSystemPointer", XorPointer),
|
||||
DECL_API("DefineDosDeviceW", DefineDosDeviceW_new),
|
||||
DECL_API("DeleteCriticalSection", DeleteCriticalSection_new),
|
||||
DECL_API("DeleteCriticalSection", DeleteCriticalSection_fix),
|
||||
DECL_API("DeleteFileW", DeleteFileW_new),
|
||||
DECL_API("EncodePointer", XorPointer),
|
||||
DECL_API("EncodeSystemPointer", XorPointer),
|
||||
DECL_API("EnterCriticalSection", EnterCriticalSection_fix),
|
||||
DECL_API("EnumUILanguagesA", EnumUILanguagesA_new),
|
||||
DECL_API("EnumUILanguagesW", EnumUILanguagesW_new),
|
||||
DECL_API("ExitProcess", ExitProcess_fix),
|
||||
DECL_API("FindAtomW", FindAtomW_new),
|
||||
DECL_API("FindFirstChangeNotificationW", FindFirstChangeNotificationW_new),
|
||||
DECL_API("FindFirstFileExW", FindFirstFileExW_stub),
|
||||
@ -170,6 +172,7 @@ static const apilib_named_api kernel32_named_apis[] =
|
||||
DECL_API("LoadLibraryExW", LoadLibraryExW_new),
|
||||
DECL_API("LoadLibraryW", LoadLibraryW_new),
|
||||
DECL_API("LockFileEx", LockFileEx_new),
|
||||
DECL_API("MapViewOfFile", MapViewOfFile_new),
|
||||
DECL_API("MapViewOfFileEx", MapViewOfFileEx_new),
|
||||
DECL_API("Module32FirstW", Module32FirstW_new),
|
||||
DECL_API("Module32NextW", Module32NextW_new),
|
||||
@ -199,6 +202,8 @@ static const apilib_named_api kernel32_named_apis[] =
|
||||
DECL_API("SearchPathW", SearchPathW_new),
|
||||
DECL_API("SetConsoleTitleW", SetConsoleTitleW_new),
|
||||
DECL_API("SetCurrentDirectoryW", SetCurrentDirectoryW_new),
|
||||
DECL_API("SetDllDirectoryA", SetDllDirectoryA_stub),
|
||||
DECL_API("SetDllDirectoryW", SetDllDirectoryW_stub),
|
||||
DECL_API("SetFileAttributesW", SetFileAttributesW_new),
|
||||
DECL_API("SetFilePointerEx", SetFilePointerEx_new),
|
||||
DECL_API("SetInformationJobObject", SetInformationJobObject_new),
|
||||
|
@ -35,7 +35,9 @@ BOOL WINAPI PostQueuedCompletionStatus_new(HANDLE CompletionPort, DWORD dwNumber
|
||||
BOOL WINAPI CopyFileExA_new(LPCSTR lpExistingFileNameA, LPCSTR lpNewFileNameA, LPPROGRESS_ROUTINE lpProgressRoutine, LPVOID lpData, LPBOOL pbCancel, DWORD dwCopyFlags);
|
||||
LPVOID WINAPI CreateFiberEx_new(SIZE_T dwStackCommitSize, SIZE_T dwStackReserveSize, DWORD dwFlags, LPFIBER_START_ROUTINE lpStartAddress, LPVOID lpParameter);
|
||||
HANDLE WINAPI CreateThread_fix(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId);
|
||||
void WINAPI DeleteCriticalSection_new(PCRITICAL_SECTION lpCriticalSection);
|
||||
void WINAPI DeleteCriticalSection_fix(PCRITICAL_SECTION lpCriticalSection);
|
||||
void WINAPI EnterCriticalSection_fix(LPCRITICAL_SECTION lpCriticalSection);
|
||||
VOID WINAPI ExitProcess_fix(UINT uExitCode);
|
||||
HANDLE WINAPI CreateFileA_fix(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDistribution, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
|
||||
BOOL WINAPI ReadFile_fix(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped);
|
||||
BOOL WINAPI WriteFile_fix(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped);
|
||||
@ -67,6 +69,7 @@ BOOL WINAPI IsProcessInJob_new(HANDLE process, HANDLE job, PBOOL result);
|
||||
void WINAPI KEXVersion(char* out);
|
||||
BOOL WINAPI LockFileEx_new(HANDLE hFile, DWORD dwFlags, DWORD dwReserved, DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh, LPOVERLAPPED lpOverlapped);
|
||||
LPVOID WINAPI MapViewOfFileEx_new(HANDLE hFileMappingObject, DWORD dwDesiredAccess, DWORD dwFileOffsetHigh, DWORD dwFileOffsetLow, SIZE_T dwNumberOfBytesToMap, LPVOID lpBaseAddress);
|
||||
LPVOID WINAPI MapViewOfFile_new(HANDLE hFileMappingObject, DWORD dwDesiredAccess, DWORD dwFileOffsetHigh, DWORD dwFileOffsetLow, SIZE_T dwNumberOfBytesToMap);
|
||||
BOOL WINAPI MoveFileExA_new(LPCSTR lpExistingFileNameA, LPCSTR lpNewFileNameA, DWORD dwFlags);
|
||||
BOOL WINAPI MoveFileWithProgressA_new(LPCSTR lpExistingFileName, LPCSTR lpNewFileName, LPPROGRESS_ROUTINE lpProgressRoutine, LPVOID lpData, DWORD dwFlags);
|
||||
HANDLE WINAPI OpenThread_new(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwThreadId);
|
||||
@ -88,6 +91,8 @@ STUB GetProcessIoCounters_stub;
|
||||
STUB RtlCaptureStackBackTrace_stub;
|
||||
STUB GetComputerNameExA_stub;
|
||||
STUB GetComputerNameExW_stub;
|
||||
STUB SetDllDirectoryA_stub;
|
||||
STUB SetDllDirectoryW_stub;
|
||||
INT WINAPI CompareStringW_new(LCID lcid, DWORD style, LPCWSTR str1, INT len1, LPCWSTR str2, INT len2);
|
||||
BOOL WINAPI GetStringTypeW_new(DWORD type, LPCWSTR src, INT count, LPWORD chartype);
|
||||
BOOL WINAPI GetStringTypeExW_new(LCID locale, DWORD type, LPCWSTR src, INT count, LPWORD chartype);
|
||||
|
@ -32,3 +32,5 @@ UNIMPL_FUNC(GetProcessIoCounters, 2);
|
||||
UNIMPL_FUNC(RtlCaptureStackBackTrace, 4);
|
||||
UNIMPL_FUNC(GetComputerNameExA, 3);
|
||||
UNIMPL_FUNC(GetComputerNameExW, 3);
|
||||
UNIMPL_FUNC(SetDllDirectoryA, 1);
|
||||
UNIMPL_FUNC(SetDllDirectoryW, 1);
|
||||
|
99
apilibs/kexbases/User32/Menu.c
Executable file
99
apilibs/kexbases/User32/Menu.c
Executable file
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* KernelEx
|
||||
* Copyright (C) 2010, Tihiy
|
||||
*
|
||||
* This file is part of KernelEx source code.
|
||||
*
|
||||
* KernelEx is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published
|
||||
* by the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* KernelEx is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Make; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define MF_TYPEMASK (MF_STRING | MF_OWNERDRAW | MF_BITMAP | MF_SEPARATOR)
|
||||
|
||||
/* MAKE_EXPORT LoadMenuIndirectA=LoadMenuIndirectW */
|
||||
|
||||
/* MAKE_EXPORT LoadMenuA_fix=LoadMenuA */
|
||||
HMENU WINAPI LoadMenuA_fix(HINSTANCE hInstance, LPCSTR lpMenuName)
|
||||
{
|
||||
//9x can't load resources from mmaped libraries (LOAD_LIBRARY_AS_DATAFILE)
|
||||
HMENU ret = NULL;
|
||||
//in case of mmaped dll the lowest bit in hInstance will be set to 1
|
||||
if ((DWORD) hInstance & 1)
|
||||
{
|
||||
HRSRC fnd = FindResource(hInstance, lpMenuName,RT_MENU);
|
||||
if (fnd)
|
||||
{
|
||||
LPMENUTEMPLATE lpMenuTemplate = LoadResource(hInstance, fnd);
|
||||
if (lpMenuTemplate)
|
||||
ret = LoadMenuIndirect(lpMenuTemplate);
|
||||
}
|
||||
}
|
||||
else
|
||||
ret = LoadMenuA(hInstance, lpMenuName);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* MAKE_EXPORT LoadMenuW_new=LoadMenuW */
|
||||
HMENU WINAPI LoadMenuW_new(HINSTANCE hInstance, LPCWSTR lpMenuNameW)
|
||||
{
|
||||
LPSTR lpMenuNameA;
|
||||
STACK_WtoA(lpMenuNameW, lpMenuNameA);
|
||||
return LoadMenuA_fix(hInstance, lpMenuNameA);
|
||||
}
|
||||
|
||||
//Append/Insert/Modify are not handled right by MSLU
|
||||
/* MAKE_EXPORT InsertMenuW_new=InsertMenuW */
|
||||
BOOL WINAPI InsertMenuW_new(HMENU hMenu, UINT uPosition, UINT uFlags,
|
||||
UINT_PTR uIDNewItem, LPCWSTR lpNewItemW)
|
||||
{
|
||||
LPSTR lpNewItemA = (LPSTR)lpNewItemW;
|
||||
if ((uFlags & MF_TYPEMASK) == MF_STRING)
|
||||
{
|
||||
STACK_WtoA(lpNewItemW, lpNewItemA);
|
||||
}
|
||||
return InsertMenuA(hMenu, uPosition, uFlags, uIDNewItem, lpNewItemA);
|
||||
}
|
||||
|
||||
/* MAKE_EXPORT AppendMenuW_new=AppendMenuW */
|
||||
BOOL WINAPI AppendMenuW_new(HMENU hMenu, UINT uFlags,
|
||||
UINT_PTR uIDNewItem, LPCWSTR lpNewItem)
|
||||
{
|
||||
return InsertMenuW_new(hMenu, -1, uFlags | MF_BYPOSITION, uIDNewItem, lpNewItem);
|
||||
}
|
||||
|
||||
/* MAKE_EXPORT ChangeMenuW_new=ChangeMenuW */
|
||||
BOOL WINAPI ChangeMenuW_new(HMENU hMenu, UINT cmd, LPCWSTR lpNewItemW,
|
||||
UINT uIDNewItem, UINT uFlags)
|
||||
{
|
||||
LPSTR lpNewItemA = (LPSTR) lpNewItemW;
|
||||
if ((uFlags & MF_TYPEMASK) == MF_STRING)
|
||||
{
|
||||
STACK_WtoA(lpNewItemW, lpNewItemA);
|
||||
}
|
||||
return ChangeMenuA(hMenu, cmd, lpNewItemA, uIDNewItem, uFlags);
|
||||
}
|
||||
|
||||
/* MAKE_EXPORT ModifyMenuW_new=ModifyMenuW */
|
||||
BOOL WINAPI ModifyMenuW_new(HMENU hMenu, UINT uPosition, UINT uFlags,
|
||||
UINT_PTR uIDNewItem, LPCWSTR lpNewItemW)
|
||||
{
|
||||
LPSTR lpNewItemA = (LPSTR) lpNewItemW;
|
||||
if ((uFlags & MF_TYPEMASK) == MF_STRING)
|
||||
{
|
||||
STACK_WtoA(lpNewItemW, lpNewItemA);
|
||||
}
|
||||
return ModifyMenuA(hMenu, uPosition, uFlags, uIDNewItem, lpNewItemA);
|
||||
}
|
76
apilibs/kexbases/User32/RawInput.c
Executable file
76
apilibs/kexbases/User32/RawInput.c
Executable file
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* KernelEx
|
||||
* Copyright (C) 2008-2010, Xeno86, Tihiy
|
||||
*
|
||||
* This file is part of KernelEx source code.
|
||||
*
|
||||
* KernelEx is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published
|
||||
* by the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* KernelEx is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Make; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
/* Raw input functions should reset output size buffers to zero.
|
||||
* While (UINT)-1 is "total failure" return, programs (e.g. mpc-hc)
|
||||
* don't check for it, and fail hard thinking it's returned buffer size.
|
||||
*/
|
||||
#define RAWNOTIMPLEMETED(intptr) \
|
||||
if (intptr) *intptr = 0; \
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED); \
|
||||
return 0;
|
||||
|
||||
|
||||
/* MAKE_EXPORT DefRawInputProc_new=DefRawInputProc */
|
||||
LRESULT WINAPI DefRawInputProc_new(PVOID paRawInput, INT nInput, UINT cbSizeHeader)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
/* MAKE_EXPORT GetRawInputBuffer_new=GetRawInputBuffer */
|
||||
UINT WINAPI GetRawInputBuffer_new(PVOID pData, PUINT pcbSize, UINT cbSizeHeader)
|
||||
{
|
||||
RAWNOTIMPLEMETED(pcbSize);
|
||||
}
|
||||
|
||||
/* MAKE_EXPORT GetRawInputData_new=GetRawInputData */
|
||||
UINT WINAPI GetRawInputData_new(PVOID hRawInput, UINT uiCommand, LPVOID pData, PUINT pcbSize, UINT cbSizeHeader)
|
||||
{
|
||||
RAWNOTIMPLEMETED(pcbSize);
|
||||
}
|
||||
|
||||
/* MAKE_EXPORT GetRawInputDeviceList_new=GetRawInputDeviceList */
|
||||
UINT WINAPI GetRawInputDeviceList_new(PVOID pRawInputDeviceList, PUINT puiNumDevices, UINT cbSize)
|
||||
{
|
||||
RAWNOTIMPLEMETED(puiNumDevices);
|
||||
}
|
||||
|
||||
/* MAKE_EXPORT GetRawInputDeviceInfo_new=GetRawInputDeviceInfoA */
|
||||
/* MAKE_EXPORT GetRawInputDeviceInfo_new=GetRawInputDeviceInfoW */
|
||||
UINT WINAPI GetRawInputDeviceInfo_new(HANDLE hDevice, UINT uiCommand, LPVOID pData, PUINT pcbSize)
|
||||
{
|
||||
RAWNOTIMPLEMETED(pcbSize);
|
||||
}
|
||||
|
||||
/* MAKE_EXPORT GetRegisteredRawInputDevices_new=GetRegisteredRawInputDevices */
|
||||
UINT WINAPI GetRegisteredRawInputDevices_new(PVOID pRawInputDevices, PUINT puiNumDevices, UINT cbSize)
|
||||
{
|
||||
RAWNOTIMPLEMETED(puiNumDevices);
|
||||
}
|
||||
|
||||
/* MAKE_EXPORT RegisterRawInputDevices_new=RegisterRawInputDevices */
|
||||
BOOL WINAPI RegisterRawInputDevices_new(PVOID pRawInputDevices, UINT uiNumDevices, UINT cbSize)
|
||||
{
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
@ -64,9 +64,11 @@ static const apilib_named_api user32_named_apis[] =
|
||||
{
|
||||
/*** AUTOGENERATED APILIST NAMED EXPORTS BEGIN ***/
|
||||
DECL_API("AllowSetForegroundWindow", AllowSetForegroundWindow_98),
|
||||
DECL_API("AppendMenuW", AppendMenuW_new),
|
||||
DECL_API("CallMsgFilterW", CallMsgFilterA),
|
||||
DECL_API("CallWindowProcA", CallWindowProcA_fix),
|
||||
DECL_API("CallWindowProcW", CallWindowProcW_new),
|
||||
DECL_API("ChangeMenuW", ChangeMenuW_new),
|
||||
DECL_API("CharLowerBuffW", CharLowerBuffW_new),
|
||||
DECL_API("CharLowerW", CharLowerW_new),
|
||||
DECL_API("CharNextExW", CharNextExW_new),
|
||||
@ -87,7 +89,7 @@ static const apilib_named_api user32_named_apis[] =
|
||||
DECL_API("DefDlgProcW", DefDlgProcW_NEW),
|
||||
DECL_API("DefFrameProcW", DefFrameProcW_NEW),
|
||||
DECL_API("DefMDIChildProcW", DefMDIChildProcW_NEW),
|
||||
DECL_API("DefRawInputProc", DefRawInputProc_stub),
|
||||
DECL_API("DefRawInputProc", DefRawInputProc_new),
|
||||
DECL_API("DefWindowProcW", DefWindowProcW_NEW),
|
||||
DECL_API("DeregisterShellHookWindow", IsWindow),
|
||||
DECL_API("DialogBoxIndirectParamW", DialogBoxIndirectParamW_NEW),
|
||||
@ -107,16 +109,17 @@ static const apilib_named_api user32_named_apis[] =
|
||||
DECL_API("GetMessageW", GetMessageW_NEW),
|
||||
DECL_API("GetMouseMovePointsEx", GetMouseMovePointsEx_98),
|
||||
DECL_API("GetNextDlgTabItem", GetNextDlgTabItem_fix),
|
||||
DECL_API("GetRawInputBuffer", GetRawInputBuffer_stub),
|
||||
DECL_API("GetRawInputData", GetRawInputData_stub),
|
||||
DECL_API("GetRawInputDeviceInfoA", GetRawInputDeviceInfoA_stub),
|
||||
DECL_API("GetRawInputDeviceInfoW", GetRawInputDeviceInfoW_stub),
|
||||
DECL_API("GetRawInputDeviceList", GetRawInputDeviceList_stub),
|
||||
DECL_API("GetRegisteredRawInputDevices", GetRegisteredRawInputDevices_stub),
|
||||
DECL_API("GetRawInputBuffer", GetRawInputBuffer_new),
|
||||
DECL_API("GetRawInputData", GetRawInputData_new),
|
||||
DECL_API("GetRawInputDeviceInfoA", GetRawInputDeviceInfo_new),
|
||||
DECL_API("GetRawInputDeviceInfoW", GetRawInputDeviceInfo_new),
|
||||
DECL_API("GetRawInputDeviceList", GetRawInputDeviceList_new),
|
||||
DECL_API("GetRegisteredRawInputDevices", GetRegisteredRawInputDevices_new),
|
||||
DECL_API("GetWindowLongA", GetWindowLongA_NEW),
|
||||
DECL_API("GetWindowLongW", GetWindowLongW_NEW),
|
||||
DECL_API("GetWindowTextLengthW", GetWindowTextLengthW_NEW),
|
||||
DECL_API("GetWindowTextW", GetWindowTextW_NEW),
|
||||
DECL_API("InsertMenuW", InsertMenuW_new),
|
||||
DECL_API("IsCharAlphaNumericW", IsCharAlphaNumericW_new),
|
||||
DECL_API("IsCharAlphaW", IsCharAlphaW_new),
|
||||
DECL_API("IsCharLowerW", IsCharLowerW_new),
|
||||
@ -124,11 +127,15 @@ static const apilib_named_api user32_named_apis[] =
|
||||
DECL_API("IsDialogMessageW", IsDialogMessageA),
|
||||
DECL_API("IsHungAppWindow", IsHungAppWindow_new),
|
||||
DECL_API("IsWindowUnicode", IsWindowUnicode_NEW),
|
||||
DECL_API("LoadMenuA", LoadMenuA_fix),
|
||||
DECL_API("LoadMenuIndirectW", LoadMenuIndirectA),
|
||||
DECL_API("LoadMenuW", LoadMenuW_new),
|
||||
DECL_API("LoadStringW", LoadStringW_new),
|
||||
DECL_API("LockSetForegroundWindow", LockSetForegroundWindow_98),
|
||||
DECL_API("LockWorkStation", LockWorkStation_new),
|
||||
DECL_API("MapVirtualKeyA", MapVirtualKeyA_new),
|
||||
DECL_API("MapVirtualKeyExA", MapVirtualKeyExA_new),
|
||||
DECL_API("ModifyMenuW", ModifyMenuW_new),
|
||||
DECL_API("OemToCharBuffW", OemToCharBuffW_new),
|
||||
DECL_API("OemToCharW", OemToCharW_new),
|
||||
DECL_API("PeekMessageA", PeekMessageA_NEW),
|
||||
@ -140,7 +147,7 @@ static const apilib_named_api user32_named_apis[] =
|
||||
DECL_API("RealGetWindowClassW", RealGetWindowClassW_new),
|
||||
DECL_API("RegisterClassExW", RegisterClassExW_NEW),
|
||||
DECL_API("RegisterClassW", RegisterClassW_NEW),
|
||||
DECL_API("RegisterRawInputDevices", RegisterRawInputDevices_stub),
|
||||
DECL_API("RegisterRawInputDevices", RegisterRawInputDevices_new),
|
||||
DECL_API("RegisterShellHookWindow", IsWindow),
|
||||
DECL_API("SendDlgItemMessageW", SendDlgItemMessageW_NEW),
|
||||
DECL_API("SendMessageA", SendMessageA_fix),
|
||||
|
@ -57,19 +57,24 @@ BOOL WINAPI IsHungAppWindow_new(HWND hWnd);
|
||||
BOOL WINAPI LockWorkStation_new(void);
|
||||
UINT WINAPI MapVirtualKeyA_new(UINT uCode, UINT uMapType);
|
||||
UINT WINAPI MapVirtualKeyExA_new(UINT uCode, UINT uMapType, HKL dwhkl);
|
||||
HMENU WINAPI LoadMenuA_fix(HINSTANCE hInstance, LPCSTR lpMenuName);
|
||||
HMENU WINAPI LoadMenuW_new(HINSTANCE hInstance, LPCWSTR lpMenuNameW);
|
||||
BOOL WINAPI InsertMenuW_new(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItemW);
|
||||
BOOL WINAPI AppendMenuW_new(HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem);
|
||||
BOOL WINAPI ChangeMenuW_new(HMENU hMenu, UINT cmd, LPCWSTR lpNewItemW, UINT uIDNewItem, UINT uFlags);
|
||||
BOOL WINAPI ModifyMenuW_new(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItemW);
|
||||
LRESULT WINAPI DefRawInputProc_new(PVOID paRawInput, INT nInput, UINT cbSizeHeader);
|
||||
UINT WINAPI GetRawInputBuffer_new(PVOID pData, PUINT pcbSize, UINT cbSizeHeader);
|
||||
UINT WINAPI GetRawInputData_new(PVOID hRawInput, UINT uiCommand, LPVOID pData, PUINT pcbSize, UINT cbSizeHeader);
|
||||
UINT WINAPI GetRawInputDeviceList_new(PVOID pRawInputDeviceList, PUINT puiNumDevices, UINT cbSize);
|
||||
UINT WINAPI GetRawInputDeviceInfo_new(HANDLE hDevice, UINT uiCommand, LPVOID pData, PUINT pcbSize);
|
||||
UINT WINAPI GetRegisteredRawInputDevices_new(PVOID pRawInputDevices, PUINT puiNumDevices, UINT cbSize);
|
||||
BOOL WINAPI RegisterRawInputDevices_new(PVOID pRawInputDevices, UINT uiNumDevices, UINT cbSize);
|
||||
LRESULT WINAPI SendMessageA_fix(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
HWND WINAPI SetParent_fix(HWND hWndChild, HWND hWndNewParent);
|
||||
BOOL WINAPI SystemParametersInfoA_fix(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni);
|
||||
BOOL WINAPI UpdateLayeredWindow_new(HWND hwnd, HDC hdcDst, POINT *pptDst, SIZE *psize, HDC hdcSrc, POINT *pptSrc, COLORREF crKey, BLENDFUNCTION *pblend, DWORD dwFlags);
|
||||
STUB SetLayeredWindowAttributes_stub;
|
||||
STUB DefRawInputProc_stub;
|
||||
STUB GetRawInputBuffer_stub;
|
||||
STUB GetRawInputData_stub;
|
||||
STUB GetRawInputDeviceList_stub;
|
||||
STUB GetRawInputDeviceInfoA_stub;
|
||||
STUB GetRawInputDeviceInfoW_stub;
|
||||
STUB GetRegisteredRawInputDevices_stub;
|
||||
STUB RegisterRawInputDevices_stub;
|
||||
STUB PrintWindow_stub;
|
||||
LPWSTR WINAPI CharNextExW_new(WORD codepage, LPCWSTR ptr, DWORD flags);
|
||||
LPWSTR WINAPI CharNextW_new(LPCWSTR x);
|
||||
|
@ -22,14 +22,4 @@
|
||||
#include "common.h"
|
||||
|
||||
UNIMPL_FUNC(SetLayeredWindowAttributes, 4);
|
||||
//raw input APIs
|
||||
UNIMPL_FUNC(DefRawInputProc, 3);
|
||||
UNIMPL_FUNC(GetRawInputBuffer, 3);
|
||||
UNIMPL_FUNC(GetRawInputData, 5);
|
||||
UNIMPL_FUNC(GetRawInputDeviceList, 3);
|
||||
UNIMPL_FUNC(GetRawInputDeviceInfoA, 4);
|
||||
UNIMPL_FUNC(GetRawInputDeviceInfoW, 4);
|
||||
UNIMPL_FUNC(GetRegisteredRawInputDevices, 3);
|
||||
UNIMPL_FUNC(RegisterRawInputDevices, 3);
|
||||
//
|
||||
UNIMPL_FUNC(PrintWindow, 3);
|
@ -2,7 +2,7 @@
|
||||
* KernelEx
|
||||
* Copyright 1995 Martin von Loewis
|
||||
* Copyright 1996 Alexandre Julliard
|
||||
* Copyright 2009 Tihiy
|
||||
* Copyright 2009-2010 Tihiy
|
||||
*
|
||||
* This file is part of KernelEx source code.
|
||||
*
|
||||
@ -306,6 +306,10 @@ LRESULT WINAPI CallProcAnsiWithUnicode( WNDPROC callback, HWND hwnd, UINT msg, W
|
||||
case WM_IME_CHAR:
|
||||
wParam = wparam_WtoA( msg, wParam );
|
||||
break;
|
||||
case WM_NOTIFYFORMAT:
|
||||
/* for default window procedures */
|
||||
if ( IS_SHARED(callback) && lParam == NF_QUERY && IsWindowUnicode_NEW((HWND)wParam) )
|
||||
return NFR_UNICODE;
|
||||
}
|
||||
return CallWindowProcA(callback,hwnd,msg,wParam,lParam);
|
||||
}
|
||||
@ -318,9 +322,13 @@ LRESULT WINAPI CallProcAnsiWithUnicode( WNDPROC callback, HWND hwnd, UINT msg, W
|
||||
LRESULT WINAPI CallProcUnicodeWithAnsi( WNDPROC callback, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (msg)
|
||||
{
|
||||
{
|
||||
case WM_NCCREATE:
|
||||
/* unicode window is being created? mark it before event fires */
|
||||
if (IsWindowReallyUnicode(hwnd))
|
||||
SetWindowUnicode(hwnd,TRUE);
|
||||
//fall down
|
||||
case WM_CREATE:
|
||||
case WM_NCCREATE:
|
||||
{
|
||||
if (!VALID_PTR(lParam)) return CallWindowProc_stdcall(callback,hwnd,msg,wParam,lParam);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* KernelEx Thunking Unicode Layer
|
||||
*
|
||||
* Copyright (C) 2009, Tihiy
|
||||
* Copyright (C) 2009-2010, Tihiy
|
||||
*
|
||||
* This file is part of KernelEx source code.
|
||||
*
|
||||
@ -35,7 +35,8 @@ static CRITICAL_SECTION wndproc_cs;
|
||||
|
||||
static HMODULE g_hUser32;
|
||||
|
||||
#define SetWinCreateEvent(proc) SetWinEventHook(EVENT_OBJECT_CREATE, EVENT_OBJECT_CREATE, g_hUser32, (WINEVENTPROC)(proc), GetCurrentProcessId(), GetCurrentThreadId(), WINEVENT_INCONTEXT)
|
||||
#define SetWinCreateEvent(proc) SetWinEventHook(EVENT_OBJECT_CREATE, EVENT_OBJECT_CREATE, g_hUser32, \
|
||||
(WINEVENTPROC)(proc), GetCurrentProcessId(), GetCurrentThreadId(), WINEVENT_INCONTEXT)
|
||||
|
||||
BOOL InitUniThunkLayer()
|
||||
{
|
||||
@ -100,8 +101,11 @@ BOOL IsWindowReallyUnicode(HWND hwnd)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* maybe we'll export this for comdlg32 */
|
||||
void WINAPI SetWindowUnicode(HWND hWnd, BOOL bUnicode)
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
__declspec(dllexport)
|
||||
void SetWindowUnicode(HWND hWnd, BOOL bUnicode)
|
||||
{
|
||||
GrabWin16Lock();
|
||||
_SetWindowUnicode( HWNDtoPWND(hWnd), bUnicode );
|
||||
@ -253,7 +257,6 @@ LONG WINAPI GetWindowLongW_NEW(HWND hWnd, int nIndex)
|
||||
SetLastError(ERROR_ACCESS_DENIED);
|
||||
return 0L;
|
||||
}
|
||||
DBGPRINTF(("GetWindowProcW: %p(A) -> %p(W)\n",ret,ConvertWndProcAToW((WNDPROC)ret)));
|
||||
ret = (LONG)ConvertWndProcAToW( (WNDPROC)ret );
|
||||
}
|
||||
return ret;
|
||||
@ -270,7 +273,6 @@ LONG WINAPI SetWindowLongW_NEW(HWND hWnd, int nIndex, LONG dwNewLong)
|
||||
SetLastError(ERROR_ACCESS_DENIED);
|
||||
return 0L;
|
||||
}
|
||||
DBGPRINTF(("SetWindowProcW[(%p)new]: %p(W) => %p(A)\n",hWnd,dwNewLong,ConvertWndProcWToA((WNDPROC)dwNewLong)));
|
||||
dwNewLong = (LONG)ConvertWndProcWToA( (WNDPROC)dwNewLong );
|
||||
}
|
||||
|
||||
@ -278,7 +280,6 @@ LONG WINAPI SetWindowLongW_NEW(HWND hWnd, int nIndex, LONG dwNewLong)
|
||||
|
||||
if ( nIndex == GWL_WNDPROC && ret ) //oh, you're unicode subclassed!
|
||||
{
|
||||
DBGPRINTF(("SetWindowProcW[(%p)old]: %p(A) => %p(W)\n",hWnd,ret,ConvertWndProcAToW((WNDPROC)ret)));
|
||||
SetWindowUnicode( hWnd, TRUE );
|
||||
ret = (LONG)ConvertWndProcAToW( (WNDPROC)ret );
|
||||
}
|
||||
@ -406,7 +407,7 @@ static void CALLBACK UnicodeEvent( HWINEVENTHOOK hWinEventHook, DWORD event, HWN
|
||||
else
|
||||
{
|
||||
THUNKPROC proc = (THUNKPROC)_GetWindowProc32( pwnd );
|
||||
if ( (DWORD)proc & 0x80000000 || (proc && proc->sign == wtoa_code && IsValidThunk(proc)) ) //shared control or Unicode thunk
|
||||
if ( IS_SHARED(proc) || (proc && proc->sign == wtoa_code && IsValidThunk(proc)) ) //shared control or Unicode thunk
|
||||
isUnicode = TRUE;
|
||||
}
|
||||
if ( isUnicode ) _SetWindowUnicode( pwnd, TRUE );
|
||||
@ -463,9 +464,7 @@ HWND WINAPI CreateDialogParamW_NEW( HINSTANCE hInstance, LPCTSTR lpTemplateName,
|
||||
|
||||
STACK_WtoA(lpTemplateName, lpTemplateNameA);
|
||||
uniEvent = SetWinCreateEvent(UnicodeEvent);
|
||||
DBGPRINTF(("CreateDialogParamW started (proc %p), eventhook %p\n",lpDialogFunc,uniEvent));
|
||||
ret = CreateDialogParamA( hInstance, lpTemplateNameA, hWndParent, lpDialogFunc, dwInitParam );
|
||||
DBGPRINTF(("CreateDialogParamW finished: %p\n",ret));
|
||||
UnhookWinEvent(uniEvent);
|
||||
return ret;
|
||||
}
|
||||
@ -477,7 +476,6 @@ HWND WINAPI CreateDialogIndirectParamW_NEW( HINSTANCE hInstance, LPCDLGTEMPLATE
|
||||
HWND ret;
|
||||
|
||||
uniEvent = SetWinCreateEvent(UnicodeEvent);
|
||||
DBGPRINTF(("CreateDialogIndirectParamW started (proc %p), eventhook %p\n",lpDialogFunc,uniEvent));
|
||||
ret = CreateDialogIndirectParamA( hInstance, lpTemplate, hWndParent, lpDialogFunc, lParamInit );
|
||||
UnhookWinEvent(uniEvent);
|
||||
return ret;
|
||||
@ -492,7 +490,6 @@ INT_PTR WINAPI DialogBoxParamW_NEW( HINSTANCE hInstance, LPCWSTR lpTemplateName
|
||||
|
||||
STACK_WtoA( lpTemplateName, lpTemplateNameA );
|
||||
uniEvent = SetWinCreateEvent(UnicodeEvent);
|
||||
DBGPRINTF(("DialogBoxParamW started (proc %p), eventhook %p\n",lpDialogFunc,uniEvent));
|
||||
ret = DialogBoxParamA( hInstance, lpTemplateNameA, hWndParent, lpDialogFunc, dwInitParam );
|
||||
UnhookWinEvent(uniEvent);
|
||||
return ret;
|
||||
@ -506,7 +503,6 @@ INT_PTR WINAPI DialogBoxIndirectParamW_NEW( HINSTANCE hInstance, LPCDLGTEMPLATE
|
||||
|
||||
|
||||
uniEvent = SetWinCreateEvent(UnicodeEvent);
|
||||
DBGPRINTF(("DialogBoxIndirectParamW started (proc %p), eventhook %p\n",lpDialogFunc,uniEvent));
|
||||
ret = DialogBoxIndirectParamA( hInstance, hDialogTemplate, hWndParent, lpDialogFunc, dwInitParam );
|
||||
UnhookWinEvent(uniEvent);
|
||||
return ret;
|
||||
@ -552,12 +548,11 @@ LRESULT WINAPI DefWindowProcW_NEW( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lP
|
||||
BOOL WINAPI SetWindowTextW_NEW( HWND hWnd, LPCWSTR lpString)
|
||||
{
|
||||
if ( !hWnd || !lpString ) return FALSE;
|
||||
if ( !ISOURPROCESSHWND(hWnd) )
|
||||
{
|
||||
SetLastError(ERROR_ACCESS_DENIED);
|
||||
return FALSE;
|
||||
}
|
||||
return SendMessageW_NEW( hWnd, WM_SETTEXT, 0, (LPARAM)lpString );
|
||||
if ( ISOURPROCESSHWND(hWnd) )
|
||||
return SendMessageW_NEW( hWnd, WM_SETTEXT, 0, (LPARAM)lpString );
|
||||
else
|
||||
return DefWindowProcW_NEW( hWnd, WM_SETTEXT, 0, (LPARAM)lpString );
|
||||
|
||||
}
|
||||
|
||||
/* MAKE_EXPORT SetDlgItemTextW_NEW=SetDlgItemTextW */
|
||||
|
@ -11,6 +11,7 @@ static DWORD GetWindowProcessId( HWND hwnd )
|
||||
}
|
||||
|
||||
#define ISOURPROCESSHWND(hwnd) ( GetWindowProcessId(hwnd) == GetCurrentProcessId() )
|
||||
#define IS_SHARED(x) (((DWORD)x) & 0x80000000)
|
||||
|
||||
#define WS_EX_UNICODE 0x80000000
|
||||
#define WF_EX_WIN32 0x02000000
|
||||
@ -37,7 +38,14 @@ LRESULT WINAPI DefWindowProcW_NEW( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lP
|
||||
LRESULT WINAPI DefDlgProcW_NEW( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
LRESULT WINAPI DefMDIChildProcW_NEW( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
BOOL IsWindowReallyUnicode(HWND hwnd);
|
||||
BOOL WINAPI IsWindowUnicode_NEW( HWND hWnd );
|
||||
|
||||
LRESULT WINAPI SendMessageA_fix(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
BOOL InitUniThunkLayer();
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
__declspec(dllexport)
|
||||
void SetWindowUnicode(HWND hWnd, BOOL bUnicode);
|
||||
|
@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
#include <malloc.h>
|
||||
#include "common.h"
|
||||
#include "kexcoresdk.h"
|
||||
|
||||
#ifndef __THUNIMACRO_H
|
||||
@ -30,27 +31,6 @@
|
||||
|
||||
#define MAX_STACK 512
|
||||
|
||||
//In macroses: convert A<->W on stack
|
||||
#define STACK_WtoA(strW,strA) \
|
||||
strA = (LPSTR)strW; \
|
||||
if HIWORD(strW) \
|
||||
{ \
|
||||
int c = lstrlenW((LPWSTR)strW); \
|
||||
c = (c+1)*2; \
|
||||
strA = (LPSTR)alloca(c); \
|
||||
WideCharToMultiByte(CP_ACP, 0, (LPWSTR)strW, -1, (LPSTR)strA, c, NULL, NULL); \
|
||||
}
|
||||
|
||||
#define STACK_AtoW(strA,strW) \
|
||||
strW = (LPWSTR)strA; \
|
||||
if (HIWORD(strA)) \
|
||||
{ \
|
||||
int c = lstrlenA((LPSTR)strA); \
|
||||
c++; \
|
||||
strW = (LPWSTR)alloca(c*sizeof(WCHAR)); \
|
||||
MultiByteToWideChar(CP_ACP, 0, (LPSTR)strA, -1, (LPWSTR)strW, c); \
|
||||
}
|
||||
|
||||
//Out macroses: allocate buffer, call W>-<A function, convert A<->W
|
||||
#define ABUFFER_ALLOC(buffer,len) \
|
||||
int buffer##size = ((len+1) * 2); \
|
||||
|
@ -1,118 +0,0 @@
|
||||
/*
|
||||
* KernelEx
|
||||
* Copyright (C) 2008, Xeno86
|
||||
*
|
||||
* This file is part of KernelEx source code.
|
||||
*
|
||||
* KernelEx is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published
|
||||
* by the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* KernelEx is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Make; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __COMMON_H
|
||||
#define __COMMON_H
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <malloc.h>
|
||||
#include "kexcoresdk.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void* __cdecl recalloc(void* ptr, size_t size);
|
||||
|
||||
typedef int __stdcall STUB(void);
|
||||
typedef int __stdcall FWDPROC(void);
|
||||
|
||||
extern int acp_mcs;
|
||||
BOOL common_init(void);
|
||||
int WINAPI CommonUnimpStub(void);
|
||||
char* file_fixWprefix(char* in);
|
||||
void fatal_error(const char* msg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define UNIMPL_FUNC(name,params) \
|
||||
__asm__( ".text\n" \
|
||||
".globl _" #name "_stub@0\n" \
|
||||
"_" #name "_stub@0:\n\t" \
|
||||
"xor %eax, %eax\n\t" \
|
||||
"movb $" #params ", %cl\n\t" \
|
||||
"jmp _CommonUnimpStub@0\n\t" \
|
||||
)
|
||||
#else
|
||||
#define UNIMPL_FUNC(name,params) \
|
||||
int __declspec(naked) __stdcall name##_stub() \
|
||||
{ \
|
||||
__asm xor eax,eax \
|
||||
__asm mov cl, params \
|
||||
__asm jmp CommonUnimpStub \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define AtoW(str, bsize) MultiByteToWideChar(CP_ACP, 0, str##A, -1, str##W, bsize)
|
||||
#define WtoA(str, bsize) WideCharToMultiByte(CP_ACP, 0, str##W, -1, str##A, bsize, NULL, NULL)
|
||||
|
||||
#define _ALLOC_WtoA(str) \
|
||||
const WCHAR* p; \
|
||||
int c; \
|
||||
for (p = str##W ; *p ; p++); \
|
||||
c = p - str##W + 1; \
|
||||
c *= acp_mcs; \
|
||||
str##A = (char*) alloca(c); \
|
||||
WtoA(str, c)
|
||||
|
||||
|
||||
#define ALLOC_WtoA(str) \
|
||||
char* str##A; \
|
||||
if (str##W) \
|
||||
{ \
|
||||
_ALLOC_WtoA(str); \
|
||||
} \
|
||||
else str##A = NULL
|
||||
|
||||
#define ALLOC_A(str, cnt) \
|
||||
char* str##A = str##W ? ((char*) alloca(cnt)) : NULL
|
||||
|
||||
#define ABUFtoW(str, inbsize, outbsize) \
|
||||
MultiByteToWideChar(CP_ACP, 0, str##A, inbsize, str##W, outbsize)
|
||||
|
||||
#define file_GetCP() \
|
||||
UINT file_CP = AreFileApisANSI() ? CP_ACP : CP_OEMCP
|
||||
#define file_AtoW(str, bsize) MultiByteToWideChar(file_CP, 0, str##A, -1, str##W, bsize)
|
||||
#define file_WtoA(str, bsize) WideCharToMultiByte(file_CP, 0, str##W, -1, str##A, bsize, "_", NULL); \
|
||||
str##A = file_fixWprefix(str##A)
|
||||
|
||||
#define file_ALLOC_WtoA(str) \
|
||||
char* str##A; \
|
||||
if (str##W) \
|
||||
{ \
|
||||
const WCHAR* p; \
|
||||
int c; \
|
||||
for (p = str##W ; *p ; p++); \
|
||||
c = p - str##W + 1; \
|
||||
c *= acp_mcs; \
|
||||
str##A = (char*) alloca(c); \
|
||||
file_WtoA(str, c); \
|
||||
} \
|
||||
else str##A = NULL
|
||||
|
||||
#define file_ABUFtoW(str, cntsrc, bsize) \
|
||||
MultiByteToWideChar(file_CP, 0, str##A, cntsrc, str##W, bsize)
|
||||
|
||||
#endif
|
@ -43,7 +43,7 @@ RSC=rc.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "KERNELEXBASESHARED_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /O2 /I "." /I "../../common" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D _WIN32_WINNT=0x0500 /YX /FD /TP /GF /c
|
||||
# ADD CPP /nologo /W3 /O2 /I "." /I "../../common" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D _WIN32_WINNT=0x0500 /YX /FD /TP /GF /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x415 /d "NDEBUG"
|
||||
@ -70,7 +70,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "KERNELEXBASESHARED_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /Zi /Od /I "." /I "../../common" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D _WIN32_WINNT=0x0500 /YX /FD /TP /GZ /GF /c
|
||||
# ADD CPP /nologo /W3 /Gm /Zi /Od /I "." /I "../../common" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D _WIN32_WINNT=0x0500 /YX /FD /TP /GZ /GF /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x415 /d "_DEBUG"
|
||||
@ -125,7 +125,11 @@ SOURCE=.\Kernel32\CreateThread_fix.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Kernel32\DeleteCriticalSection.c
|
||||
SOURCE=.\Kernel32\CriticalSection_fix.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Kernel32\ExitProcess_fix.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@ -333,6 +337,14 @@ SOURCE=.\User32\MapVirtualKey_fix.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\User32\Menu.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\User32\RawInput.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\User32\SendMessage_fix.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -413,6 +425,18 @@ SOURCE=.\Gdi32\GetGlyphOutlineA_fix.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Gdi32\GetTextExtentPoint32_fix.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Gdi32\Orhpans.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Gdi32\Orhpans.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Gdi32\TextOut.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -437,6 +461,10 @@ SOURCE=.\Advapi32\_advapi32_stubs.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Advapi32\lsa.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Advapi32\OpenSCManager_stub.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -542,7 +570,7 @@ SOURCE=.\comctl32\syslink.c
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common.c
|
||||
SOURCE=..\..\common\common.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@ -636,7 +664,7 @@ SOURCE=.\main.c
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common.h
|
||||
SOURCE=..\..\common\common.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
* along with GNU Make; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
|
||||
@ -31,6 +31,8 @@ DWORD WINAPI GetFileVersionInfoSizeW_new(LPWSTR filenameW, LPDWORD handle)
|
||||
file_GetCP();
|
||||
file_ALLOC_WtoA(filename);
|
||||
size = GetFileVersionInfoSizeA(filenameA, handle);
|
||||
if (size == 0)
|
||||
return size;
|
||||
return size * (1 + sizeof(WCHAR)) + 4;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user