1
0
mirror of https://github.com/UzixLS/KernelEx.git synced 2025-07-19 07:21:20 +03:00

import KernelEx-4.5.1

This commit is contained in:
UzixLS
2018-11-03 16:23:39 +03:00
parent 7571e3c60d
commit 2948e23961
77 changed files with 2603 additions and 883 deletions

View File

@ -0,0 +1,44 @@
/*
* KernelEx
* Copyright (C) 2011, 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.
*
*/
#include <windows.h>
/* MAKE_EXPORT RegSetValueExA_fix=RegSetValueExA */
LONG WINAPI RegSetValueExA_fix(
HKEY hKey,
LPCSTR lpValueName,
DWORD Reserved,
DWORD dwType,
CONST BYTE *lpData,
DWORD cbData
)
{
if (!lpData && cbData)
return ERROR_INVALID_PARAMETER;
if (dwType == REG_SZ || dwType == REG_EXPAND_SZ || dwType == REG_MULTI_SZ)
{
if (!lpData)
lpData = (CONST BYTE*) "";
}
return RegSetValueExA(hKey, lpValueName, Reserved, dwType, lpData, cbData);
}

View File

@ -74,6 +74,8 @@ static const apilib_named_api advapi32_named_apis[] =
DECL_API("GetFileSecurityA", GetFileSecurityA_new),
DECL_API("GetFileSecurityW", GetFileSecurityW_new),
DECL_API("GetLengthSid", GetLengthSid_new),
DECL_API("GetNamedSecurityInfoA", GetNamedSecurityInfoA_new),
DECL_API("GetNamedSecurityInfoW", GetNamedSecurityInfoW_new),
DECL_API("GetSecurityDescriptorControl", GetSecurityDescriptorControl_new),
DECL_API("GetSecurityDescriptorDacl", GetSecurityDescriptorDacl_new),
DECL_API("GetSecurityDescriptorGroup", GetSecurityDescriptorGroup_new),
@ -112,11 +114,19 @@ static const apilib_named_api advapi32_named_apis[] =
DECL_API("PrivilegeCheck", PrivilegeCheck_new),
DECL_API("QueryServiceStatusEx", QueryServiceStatusEx_stub),
DECL_API("QueryWindows31FilesMigration", QueryWindows31FilesMigration_stub),
DECL_API("RegCreateKeyExW", RegCreateKeyExW_new),
DECL_API("RegCreateKeyW", RegCreateKeyW_new),
DECL_API("RegDeleteKeyW", RegDeleteKeyW_new),
DECL_API("RegDisablePredefinedCache", RegDisablePredefinedCache_new),
DECL_API("RegEnumValueW", RegEnumValueW_new),
DECL_API("RegGetKeySecurity", RegGetKeySecurity_new),
DECL_API("RegOpenCurrentUser", RegOpenCurrentUser_new),
DECL_API("RegOpenKeyExW", RegOpenKeyExW_new),
DECL_API("RegOpenKeyW", RegOpenKeyW_new),
DECL_API("RegOverridePredefKey", RegOverridePredefKey_stub),
DECL_API("RegQueryValueExW", RegQueryValueExW_new),
DECL_API("RegSetValueExA", RegSetValueExA_fix),
DECL_API("RegSetValueExW", RegSetValueExW_new),
DECL_API("RevertToSelf", RevertToSelf_new),
DECL_API("SetFileSecurityA", SetFileSecurityA_new),
DECL_API("SetFileSecurityW", SetFileSecurityW_new),

View File

@ -23,6 +23,7 @@
#define _ADVAPI32_APILIST_H
#include "kexcoresdk.h"
#include <accctrl.h>
BOOL init_advapi32();
extern const apilib_api_table apitable_advapi32;
@ -32,6 +33,7 @@ SC_HANDLE WINAPI OpenSCManagerA_stub(LPCSTR lpMachineName, LPCSTR lpDatabaseName
SC_HANDLE WINAPI OpenSCManagerW_stub(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess);
BOOL WINAPI RegDisablePredefinedCache_new();
LONG WINAPI RegOpenCurrentUser_new(REGSAM access, PHKEY retkey);
LONG WINAPI RegSetValueExA_fix(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData);
BOOL WINAPI SystemFunction036_new(PVOID pbBuffer, ULONG dwLen);
ULONG CDECL TraceMessage_new(ULONG64 LoggerHandle, ULONG MessageFlags, LPGUID MessageGuid, USHORT MessageNumber, ...);
STUB CryptAcquireContextW_stub;
@ -114,6 +116,9 @@ BOOL WINAPI LookupAccountSidA_new(IN LPCSTR system, IN PSID sid, OUT LPSTR accou
BOOL WINAPI LookupAccountSidW_new(IN LPCWSTR system, IN PSID sid, OUT LPWSTR account, IN OUT LPDWORD accountSize, OUT LPWSTR domain, IN OUT LPDWORD domainSize, OUT PSID_NAME_USE name_use);
BOOL WINAPI SetFileSecurityA_new(LPCSTR lpFileName, SECURITY_INFORMATION RequestedInformation, PSECURITY_DESCRIPTOR pSecurityDescriptor);
BOOL WINAPI SetFileSecurityW_new(LPCWSTR lpFileName, SECURITY_INFORMATION RequestedInformation, PSECURITY_DESCRIPTOR pSecurityDescriptor);
DWORD WINAPI GetNamedSecurityInfoW_new(LPWSTR name, SE_OBJECT_TYPE type, SECURITY_INFORMATION info, PSID* owner, PSID* group, PACL* dacl, PACL* sacl, PSECURITY_DESCRIPTOR* descriptor);
DWORD WINAPI GetNamedSecurityInfoA_new(LPSTR pObjectName, SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo, PSID* ppsidOwner, PSID* ppsidGroup, PACL* ppDacl, PACL* ppSacl, PSECURITY_DESCRIPTOR* ppSecurityDescriptor);
LONG WINAPI RegGetKeySecurity_new(IN HKEY hKey, IN SECURITY_INFORMATION SecurityInformation, OUT PSECURITY_DESCRIPTOR pSecurityDescriptor, IN OUT LPDWORD lpcbSecurityDescriptor);
BOOL WINAPI RevertToSelf_new(void);
BOOL WINAPI ImpersonateSelf_new(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel);
BOOL WINAPI AccessCheck_new(PSECURITY_DESCRIPTOR SecurityDescriptor, HANDLE ClientToken, DWORD DesiredAccess, PGENERIC_MAPPING GenericMapping, PPRIVILEGE_SET PrivilegeSet, LPDWORD PrivilegeSetLength, LPDWORD GrantedAccess, LPBOOL AccessStatus);
@ -124,8 +129,14 @@ BOOL WINAPI GetAce_new(PACL pAcl,DWORD dwAceIndex,LPVOID *pAce);
BOOL WINAPI DeleteAce_new(PACL pAcl, DWORD dwAceIndex);
BOOL WINAPI CreateRestrictedToken_new(HANDLE baseToken, DWORD flags, DWORD nDisableSids, PSID_AND_ATTRIBUTES disableSids, DWORD nDeletePrivs, PLUID_AND_ATTRIBUTES deletePrivs, DWORD nRestrictSids, PSID_AND_ATTRIBUTES restrictSids, PHANDLE newToken);
BOOL WINAPI CreateWellKnownSid_new(DWORD WellKnownSidType, PSID DomainSid, PSID pSid, DWORD* cbSid);
LONG WINAPI RegCreateKeyW_new(HKEY hKey, LPCWSTR lpSubKeyW, PHKEY phkResult);
LONG WINAPI RegCreateKeyExW_new(HKEY hKey, LPCWSTR lpSubKeyW, DWORD Reserved, LPWSTR lpClassW, DWORD dwOptions, REGSAM samDesired, LPSECURITY_ATTRIBUTES lpSecurityAttributes, PHKEY phkResult, LPDWORD lpdwDisposition);
LONG WINAPI RegDeleteKeyW_new(HKEY hKey, LPCWSTR lpSubKeyW);
LONG WINAPI RegOpenKeyW_new(HKEY hKey, LPCWSTR lpSubKeyW, PHKEY phkResult);
LONG WINAPI RegOpenKeyExW_new(HKEY hKey, LPCWSTR lpSubKeyW, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult);
LONG WINAPI RegQueryValueExW_new(HKEY hKey, LPCWSTR lpValueNameW, LPDWORD lpReserved, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData);
LONG WINAPI RegEnumValueW_new(HKEY hKey, DWORD dwIndex, LPWSTR lpValueName, LPDWORD lpcValueName, LPDWORD lpReserved, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData);
LONG WINAPI RegSetValueExW_new(HKEY hKey, LPCWSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData);
/*** AUTOGENERATED APILIST DECLARATIONS END ***/
#endif

View File

@ -30,6 +30,7 @@
#include <windows.h>
#include <ntsecapi.h>
#include <accctrl.h>
#include "common.h"
#include "_advapi32_apilist.h"
@ -1146,6 +1147,70 @@ BOOL WINAPI InitializeAcl_new(PACL acl, DWORD size, DWORD rev)
##############################
*/
LONG WINAPI
FillSecurityDescriptor(
IN SECURITY_INFORMATION RequestedInformation,
OUT PSECURITY_DESCRIPTOR pSecurityDescriptor,
IN ULONG nLength,
OUT PULONG lpnLengthNeeded
)
{
DWORD nNeeded;
LPBYTE pBuffer;
DWORD iLocNow;
SECURITY_DESCRIPTOR *pSDRelative;
nNeeded = sizeof(SECURITY_DESCRIPTOR);
if (RequestedInformation & OWNER_SECURITY_INFORMATION)
nNeeded += sizeof(sidWorld);
if (RequestedInformation & GROUP_SECURITY_INFORMATION)
nNeeded += sizeof(sidWorld);
if (RequestedInformation & DACL_SECURITY_INFORMATION)
nNeeded += WINE_SIZE_OF_WORLD_ACCESS_ACL;
if (RequestedInformation & SACL_SECURITY_INFORMATION)
nNeeded += WINE_SIZE_OF_WORLD_ACCESS_ACL;
*lpnLengthNeeded = nNeeded;
if (nNeeded > nLength)
return ERROR_INSUFFICIENT_BUFFER;
if (!InitializeSecurityDescriptor_new((SECURITY_DESCRIPTOR*) pSecurityDescriptor,
SECURITY_DESCRIPTOR_REVISION))
return ERROR_INVALID_SECURITY_DESCR;
pSDRelative = (PISECURITY_DESCRIPTOR) pSecurityDescriptor;
pSDRelative->Control |= SE_SELF_RELATIVE;
pBuffer = (LPBYTE) pSDRelative;
iLocNow = sizeof(SECURITY_DESCRIPTOR);
if (RequestedInformation & OWNER_SECURITY_INFORMATION)
{
memcpy(pBuffer + iLocNow, &sidWorld, sizeof(sidWorld));
pSDRelative->Owner = (PACL) iLocNow;
iLocNow += sizeof(sidWorld);
}
if (RequestedInformation & GROUP_SECURITY_INFORMATION)
{
memcpy(pBuffer + iLocNow, &sidWorld, sizeof(sidWorld));
pSDRelative->Group = (PACL) iLocNow;
iLocNow += sizeof(sidWorld);
}
if (RequestedInformation & DACL_SECURITY_INFORMATION)
{
GetWorldAccessACL((PACL) (pBuffer + iLocNow));
pSDRelative->Dacl = (PACL) iLocNow;
iLocNow += WINE_SIZE_OF_WORLD_ACCESS_ACL;
}
if (RequestedInformation & SACL_SECURITY_INFORMATION)
{
GetWorldAccessACL((PACL) (pBuffer + iLocNow));
pSDRelative->Sacl = (PACL) iLocNow;
/* iLocNow += WINE_SIZE_OF_WORLD_ACCESS_ACL; */
}
return ERROR_SUCCESS;
}
/******************************************************************************
* LookupPrivilegeValueW [ADVAPI32.@] !!20040505
* Retrieves LUID used on a system to represent the privilege name.
@ -1202,61 +1267,17 @@ GetFileSecurityW_new( LPCWSTR lpFileName,
SECURITY_DESCRIPTOR* pSecurityDescriptor,
DWORD nLength, LPDWORD lpnLengthNeeded )
{
DWORD nNeeded;
LPBYTE pBuffer;
DWORD iLocNow;
SECURITY_DESCRIPTOR *pSDRelative;
LONG res;
FIXMEW("GetFileSecurityW(%s) : returns fake SECURITY_DESCRIPTOR\n", lpFileName);
nNeeded = sizeof(SECURITY_DESCRIPTOR);
if (RequestedInformation & OWNER_SECURITY_INFORMATION)
nNeeded += sizeof(sidWorld);
if (RequestedInformation & GROUP_SECURITY_INFORMATION)
nNeeded += sizeof(sidWorld);
if (RequestedInformation & DACL_SECURITY_INFORMATION)
nNeeded += WINE_SIZE_OF_WORLD_ACCESS_ACL;
if (RequestedInformation & SACL_SECURITY_INFORMATION)
nNeeded += WINE_SIZE_OF_WORLD_ACCESS_ACL;
res = FillSecurityDescriptor(RequestedInformation, pSecurityDescriptor, nLength, lpnLengthNeeded);
*lpnLengthNeeded = nNeeded;
if (nNeeded > nLength)
return TRUE;
if (!InitializeSecurityDescriptor_new(pSecurityDescriptor, SECURITY_DESCRIPTOR_REVISION))
return FALSE;
pSDRelative = (PISECURITY_DESCRIPTOR) pSecurityDescriptor;
pSDRelative->Control |= SE_SELF_RELATIVE;
pBuffer = (LPBYTE) pSDRelative;
iLocNow = sizeof(SECURITY_DESCRIPTOR);
if (RequestedInformation & OWNER_SECURITY_INFORMATION)
{
memcpy(pBuffer + iLocNow, &sidWorld, sizeof(sidWorld));
pSDRelative->Owner = (PACL) iLocNow;
iLocNow += sizeof(sidWorld);
}
if (RequestedInformation & GROUP_SECURITY_INFORMATION)
{
memcpy(pBuffer + iLocNow, &sidWorld, sizeof(sidWorld));
pSDRelative->Group = (PACL) iLocNow;
iLocNow += sizeof(sidWorld);
}
if (RequestedInformation & DACL_SECURITY_INFORMATION)
{
GetWorldAccessACL((PACL) (pBuffer + iLocNow));
pSDRelative->Dacl = (PACL) iLocNow;
iLocNow += WINE_SIZE_OF_WORLD_ACCESS_ACL;
}
if (RequestedInformation & SACL_SECURITY_INFORMATION)
{
GetWorldAccessACL((PACL) (pBuffer + iLocNow));
pSDRelative->Sacl = (PACL) iLocNow;
/* iLocNow += WINE_SIZE_OF_WORLD_ACCESS_ACL; */
}
return TRUE;
if (res == ERROR_SUCCESS)
return TRUE;
if (res == ERROR_INSUFFICIENT_BUFFER)
return TRUE;
return FALSE;
}
/******************************************************************************
@ -1400,6 +1421,160 @@ SetFileSecurityW_new( LPCWSTR lpFileName,
return TRUE;
}
/******************************************************************************
* GetNamedSecurityInfoW [ADVAPI32.@]
*/
/* MAKE_EXPORT GetNamedSecurityInfoW_new=GetNamedSecurityInfoW */
DWORD WINAPI GetNamedSecurityInfoW_new( LPWSTR name, SE_OBJECT_TYPE type,
SECURITY_INFORMATION info, PSID* owner, PSID* group, PACL* dacl,
PACL* sacl, PSECURITY_DESCRIPTOR* descriptor )
{
DWORD needed, offset;
SECURITY_DESCRIPTOR_RELATIVE *relative = NULL;
BYTE *buffer;
TRACE( "%s %d %d %p %p %p %p %p\n", debugstr_w(name), type, info, owner,
group, dacl, sacl, descriptor );
/* A NULL descriptor is allowed if any one of the other pointers is not NULL */
if (!name || !(owner||group||dacl||sacl||descriptor) ) return ERROR_INVALID_PARAMETER;
/* If no descriptor, we have to check that there's a pointer for the requested information */
if( !descriptor && (
((info & OWNER_SECURITY_INFORMATION) && !owner)
|| ((info & GROUP_SECURITY_INFORMATION) && !group)
|| ((info & DACL_SECURITY_INFORMATION) && !dacl)
|| ((info & SACL_SECURITY_INFORMATION) && !sacl) ))
return ERROR_INVALID_PARAMETER;
needed = !descriptor ? 0 : sizeof(SECURITY_DESCRIPTOR_RELATIVE);
if (info & OWNER_SECURITY_INFORMATION)
needed += sizeof(sidWorld);
if (info & GROUP_SECURITY_INFORMATION)
needed += sizeof(sidWorld);
if (info & DACL_SECURITY_INFORMATION)
needed += WINE_SIZE_OF_WORLD_ACCESS_ACL;
if (info & SACL_SECURITY_INFORMATION)
needed += WINE_SIZE_OF_WORLD_ACCESS_ACL;
if(descriptor)
{
/* must be freed by caller */
*descriptor = HeapAlloc( GetProcessHeap(), 0, needed );
if (!*descriptor) return ERROR_NOT_ENOUGH_MEMORY;
if (!InitializeSecurityDescriptor_new( (SECURITY_DESCRIPTOR*) *descriptor, SECURITY_DESCRIPTOR_REVISION ))
{
HeapFree( GetProcessHeap(), 0, *descriptor );
return ERROR_INVALID_SECURITY_DESCR;
}
relative = (SECURITY_DESCRIPTOR_RELATIVE*) *descriptor;
relative->Control |= SE_SELF_RELATIVE;
buffer = (BYTE *)relative;
offset = sizeof(SECURITY_DESCRIPTOR_RELATIVE);
}
else
{
buffer = (BYTE*) HeapAlloc( GetProcessHeap(), 0, needed );
if (!buffer) return ERROR_NOT_ENOUGH_MEMORY;
offset = 0;
}
if (info & OWNER_SECURITY_INFORMATION)
{
memcpy( buffer + offset, &sidWorld, sizeof(sidWorld) );
if(relative)
relative->Owner = offset;
if (owner)
*owner = buffer + offset;
offset += sizeof(sidWorld);
}
if (info & GROUP_SECURITY_INFORMATION)
{
memcpy( buffer + offset, &sidWorld, sizeof(sidWorld) );
if(relative)
relative->Group = offset;
if (group)
*group = buffer + offset;
offset += sizeof(sidWorld);
}
if (info & DACL_SECURITY_INFORMATION)
{
GetWorldAccessACL( (PACL)(buffer + offset) );
if(relative)
{
relative->Control |= SE_DACL_PRESENT;
relative->Dacl = offset;
}
if (dacl)
*dacl = (PACL)(buffer + offset);
offset += WINE_SIZE_OF_WORLD_ACCESS_ACL;
}
if (info & SACL_SECURITY_INFORMATION)
{
GetWorldAccessACL( (PACL)(buffer + offset) );
if(relative)
{
relative->Control |= SE_SACL_PRESENT;
relative->Sacl = offset;
}
if (sacl)
*sacl = (PACL)(buffer + offset);
}
return ERROR_SUCCESS;
}
/******************************************************************************
* GetNamedSecurityInfoA [ADVAPI32.@]
*/
/* MAKE_EXPORT GetNamedSecurityInfoA_new=GetNamedSecurityInfoA */
DWORD WINAPI GetNamedSecurityInfoA_new(LPSTR pObjectName,
SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo,
PSID* ppsidOwner, PSID* ppsidGroup, PACL* ppDacl, PACL* ppSacl,
PSECURITY_DESCRIPTOR* ppSecurityDescriptor)
{
DWORD len;
LPWSTR wstr = NULL;
DWORD r;
TRACE("%s %d %d %p %p %p %p %p\n", pObjectName, ObjectType, SecurityInfo,
ppsidOwner, ppsidGroup, ppDacl, ppSacl, ppSecurityDescriptor);
if( pObjectName )
{
len = MultiByteToWideChar( CP_ACP, 0, pObjectName, -1, NULL, 0 );
wstr = (LPWSTR) HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR));
MultiByteToWideChar( CP_ACP, 0, pObjectName, -1, wstr, len );
}
r = GetNamedSecurityInfoW_new( wstr, ObjectType, SecurityInfo, ppsidOwner,
ppsidGroup, ppDacl, ppSacl, ppSecurityDescriptor );
HeapFree( GetProcessHeap(), 0, wstr );
return r;
}
/* MAKE_EXPORT RegGetKeySecurity_new=RegGetKeySecurity */
LONG WINAPI RegGetKeySecurity_new(
IN HKEY hKey,
IN SECURITY_INFORMATION SecurityInformation,
OUT PSECURITY_DESCRIPTOR pSecurityDescriptor,
IN OUT LPDWORD lpcbSecurityDescriptor
)
{
TRACE("(%x,%ld,%p,%ld)\n",hkey,SecurityInformation,pSecurityDescriptor,
pSecurityDescriptor?*pSecurityDescriptor:0);
if (!lpcbSecurityDescriptor)
return ERROR_INVALID_PARAMETER;
return FillSecurityDescriptor(SecurityInformation, pSecurityDescriptor,
*lpcbSecurityDescriptor, lpcbSecurityDescriptor);
}
#if 0 /* LSA disabled */
/******************************************************************************

View File

@ -1,6 +1,6 @@
/*
* KernelEx
* Copyright (C) 2008-2009, Xeno86
* Copyright (C) 2008-2011, Xeno86
* Copyright (C) 2009, Tihiy
*
* This file is part of KernelEx source code.
@ -21,10 +21,87 @@
*/
#include "common.h"
#include "_advapi32_apilist.h"
//MAKE_EXPORT RegCreateKeyW_new=RegCreateKeyW
LONG WINAPI RegCreateKeyW_new(
HKEY hKey,
LPCWSTR lpSubKeyW,
PHKEY phkResult
)
{
LPSTR lpSubKeyA;
STACK_WtoA(lpSubKeyW, lpSubKeyA);
return RegCreateKeyA(hKey, lpSubKeyA, phkResult);
}
//MAKE_EXPORT RegCreateKeyExW_new=RegCreateKeyExW
LONG WINAPI RegCreateKeyExW_new(
HKEY hKey,
LPCWSTR lpSubKeyW,
DWORD Reserved,
LPWSTR lpClassW,
DWORD dwOptions,
REGSAM samDesired,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
PHKEY phkResult,
LPDWORD lpdwDisposition
)
{
LPSTR lpSubKeyA;
LPSTR lpClassA;
STACK_WtoA(lpSubKeyW, lpSubKeyA);
STACK_WtoA(lpClassW, lpClassA);
return RegCreateKeyExA(hKey, lpSubKeyA, Reserved, lpClassA, dwOptions,
samDesired, lpSecurityAttributes, phkResult, lpdwDisposition);
}
//MAKE_EXPORT RegDeleteKeyW_new=RegDeleteKeyW
LONG WINAPI RegDeleteKeyW_new(
HKEY hKey,
LPCWSTR lpSubKeyW
)
{
LPSTR lpSubKeyA;
STACK_WtoA(lpSubKeyW, lpSubKeyA);
return RegDeleteKeyA(hKey, lpSubKeyA);
}
//MAKE_EXPORT RegOpenKeyW_new=RegOpenKeyW
LONG WINAPI RegOpenKeyW_new(
HKEY hKey,
LPCWSTR lpSubKeyW,
PHKEY phkResult
)
{
LPSTR lpSubKeyA;
STACK_WtoA(lpSubKeyW, lpSubKeyA);
return RegOpenKeyA(hKey, lpSubKeyA, phkResult);
}
//MAKE_EXPORT RegOpenKeyExW_new=RegOpenKeyExW
LONG WINAPI RegOpenKeyExW_new(
HKEY hKey,
LPCWSTR lpSubKeyW,
DWORD ulOptions,
REGSAM samDesired,
PHKEY phkResult
)
{
LPSTR lpSubKeyA;
STACK_WtoA(lpSubKeyW, lpSubKeyA);
return RegOpenKeyExA(hKey, lpSubKeyA, ulOptions, samDesired, phkResult);
}
//MAKE_EXPORT RegQueryValueExW_new=RegQueryValueExW
LONG WINAPI RegQueryValueExW_new(HKEY hKey, LPCWSTR lpValueNameW, LPDWORD lpReserved,
LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData)
LONG WINAPI RegQueryValueExW_new(
HKEY hKey,
LPCWSTR lpValueNameW,
LPDWORD lpReserved,
LPDWORD lpType,
LPBYTE lpData,
LPDWORD lpcbData
)
{
LONG ret;
DWORD type;
@ -167,3 +244,36 @@ LONG WINAPI RegEnumValueW_new(
if (heapbuf) HeapFree(GetProcessHeap(), 0, heapbuf);
return ret;
}
/* MAKE_EXPORT RegSetValueExW_new=RegSetValueExW */
LONG WINAPI RegSetValueExW_new(
HKEY hKey,
LPCWSTR lpValueName,
DWORD Reserved,
DWORD dwType,
CONST BYTE *lpData,
DWORD cbData
)
{
LPSTR strA;
STACK_WtoA(lpValueName, strA);
if (dwType == REG_SZ || dwType == REG_EXPAND_SZ || dwType == REG_MULTI_SZ)
{
if (HIWORD(lpData))
{
LPSTR lpDataA;
int cbDataA;
cbData = (cbData + 1) / 2;
cbDataA = WideCharToMultiByte(CP_ACP, 0, (LPWSTR) lpData, cbData, NULL, 0, NULL, NULL);
lpDataA = (LPSTR) alloca(cbDataA + 1);
WideCharToMultiByte(CP_ACP, 0, (LPWSTR) lpData, cbData, lpDataA, cbDataA, NULL, NULL);
lpDataA[cbDataA] = 0;
lpData = (CONST BYTE*) lpDataA;
}
}
return RegSetValueExA_fix(hKey, strA, Reserved, dwType, lpData, cbData);
}

View File

@ -0,0 +1,32 @@
/*
* KernelEx
* Copyright (C) 2011, 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.
*
*/
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
/* MAKE_EXPORT MaskBlt_new=MaskBlt */
BOOL WINAPI MaskBlt_new(HDC hdcDest, INT nXDest, INT nYDest,
INT nWidth, INT nHeight, HDC hdcSrc,
INT nXSrc, INT nYSrc, HBITMAP hbmMask,
INT xMask, INT yMask, DWORD dwRop)
{
return BitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop & 0x00FFFFFF);
}

View File

@ -64,6 +64,7 @@ static const apilib_named_api gdi32_named_apis[] =
DECL_API("GetTextExtentPoint32W", GetTextExtentPoint32W_fix),
DECL_API("GetTextMetricsA", GetTextMetricsA_NT),
DECL_API("GetWorldTransform", GetWorldTransform_NT),
DECL_API("MaskBlt", MaskBlt_new),
DECL_API("ModifyWorldTransform", ModifyWorldTransform_NT),
DECL_API("PolyTextOutA", PolyTextOutA_new),
DECL_API("PolyTextOutW", PolyTextOutW_new),

View File

@ -44,6 +44,7 @@ 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);
BOOL WINAPI MaskBlt_new(HDC hdcDest, INT nXDest, INT nYDest, INT nWidth, INT nHeight, HDC hdcSrc, INT nXSrc, INT nYSrc, HBITMAP hbmMask, INT xMask, INT yMask, DWORD dwRop);
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);

View File

@ -101,6 +101,7 @@ static const apilib_named_api kernel32_named_apis[] =
DECL_API("GetFileAttributesW", GetFileAttributesW_new),
DECL_API("GetFileSizeEx", GetFileSizeEx_new),
DECL_API("GetFullPathNameW", GetFullPathNameW_new),
DECL_API("GetLocaleInfoW", GetLocaleInfoW_new),
DECL_API("GetLongPathNameW", GetLongPathNameW_new),
DECL_API("GetModuleFileNameW", GetModuleFileNameW_new),
DECL_API("GetModuleHandleExA", GetModuleHandleExA_new),
@ -208,6 +209,7 @@ static const apilib_named_api kernel32_named_apis[] =
DECL_API("SetFileAttributesW", SetFileAttributesW_new),
DECL_API("SetFilePointerEx", SetFilePointerEx_new),
DECL_API("SetInformationJobObject", SetInformationJobObject_new),
DECL_API("SetThreadUILanguage", SetThreadUILanguage_new),
DECL_API("SystemTimeToTzSpecificLocalTime", SystemTimeToTzSpecificLocalTime_new),
DECL_API("TerminateJobObject", TerminateJobObject_new),
DECL_API("TryEnterCriticalSection", TryEnterCriticalSection_new),

View File

@ -109,6 +109,7 @@ LANGID WINAPI GetUserDefaultUILanguage_new(void);
LANGID WINAPI GetSystemDefaultUILanguage_new(void);
BOOL WINAPI EnumUILanguagesA_new(UILANGUAGE_ENUMPROCA pUILangEnumProc, DWORD dwFlags, LONG_PTR lParam);
BOOL WINAPI EnumUILanguagesW_new(UILANGUAGE_ENUMPROCW pUILangEnumProc, DWORD dwFlags, LONG_PTR lParam);
LANGID WINAPI SetThreadUILanguage_new(LANGID LangId);
ATOM WINAPI AddAtomW_new(LPCWSTR strW);
BOOL WINAPI CopyFileExW_new(LPCWSTR lpExistingFileNameW, LPCWSTR lpNewFileNameW, LPPROGRESS_ROUTINE lpProgressRoutine, LPVOID lpData, LPBOOL pbCancel, DWORD dwCopyFlags);
BOOL WINAPI CopyFileW_new(LPCWSTR lpExistingFileNameW, LPCWSTR lpNewFileNameW, BOOL bFailIfExists);
@ -133,6 +134,7 @@ void* WINAPI GetEnvironmentStringsW_new(void);
BOOL WINAPI GetFileAttributesExW_new(LPCWSTR lpFileNameW, GET_FILEEX_INFO_LEVELS fInfoLevelId, LPVOID lpFileInformation);
DWORD WINAPI GetFileAttributesW_new(LPCWSTR lpFileNameW);
DWORD WINAPI GetFullPathNameW_new(LPCWSTR lpFileNameW, DWORD nBufferLength, LPWSTR lpBufferW, LPWSTR *lpFilePartW);
int WINAPI GetLocaleInfoW_new(LCID Locale, LCTYPE LCType, LPWSTR lpLCData, int cchData);
DWORD WINAPI GetLongPathNameW_new(LPCWSTR lpszShortPathW, LPWSTR lpszLongPathW, DWORD cchBuffer);
DWORD WINAPI GetModuleFileNameW_new(HMODULE hModule, LPWSTR lpFilenameW, DWORD nSize);
HMODULE WINAPI GetModuleHandleW_new(LPCWSTR lpModuleNameW);

View File

@ -158,3 +158,9 @@ BOOL WINAPI EnumUILanguagesW_new(UILANGUAGE_ENUMPROCW pUILangEnumProc, DWORD dwF
pUILangEnumProc(buf, lParam);
return TRUE;
}
/* MAKE_EXPORT SetThreadUILanguage_new=SetThreadUILanguage */
LANGID WINAPI SetThreadUILanguage_new(LANGID LangId)
{
return LangId;
}

View File

@ -314,6 +314,48 @@ DWORD WINAPI GetFullPathNameW_new(LPCWSTR lpFileNameW, DWORD nBufferLength, LPWS
}
return ret;
}
static int GetCPFromLocale(LCID Locale)
{
int cp;
Locale = LOWORD(Locale);
if (GetLocaleInfoA(Locale, LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER, (LPSTR)&cp, sizeof(int)))
return cp;
else
return CP_ACP;
}
/* MAKE_EXPORT GetLocaleInfoW_new=GetLocaleInfoW */
int WINAPI GetLocaleInfoW_new(
LCID Locale,
LCTYPE LCType,
LPWSTR lpLCData,
int cchData
)
{
int cp;
int ret;
char *buf;
if ((LCType & LOCALE_RETURN_NUMBER) || (cchData == 0))
return GetLocaleInfoA(Locale, LCType, (LPSTR) lpLCData, cchData * 2);
if (!lpLCData)
{
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
buf = (char*) alloca(cchData * 2);
buf[0] = 0;
ret = GetLocaleInfoA(Locale, LCType, buf, cchData * 2);
if (!ret)
return ret;
if (LCType & LOCALE_USE_CP_ACP)
cp = CP_ACP;
else
cp = GetCPFromLocale(Locale);
ret = MultiByteToWideChar(cp, 0, buf, -1, lpLCData, cchData);
return ret;
}
//MAKE_EXPORT GetLongPathNameW_new=GetLongPathNameW
DWORD WINAPI GetLongPathNameW_new(LPCWSTR lpszShortPathW, LPWSTR lpszLongPathW, DWORD cchBuffer)

View File

@ -437,6 +437,10 @@ SOURCE=.\Gdi32\GetTextExtentPoint32_fix.c
# End Source File
# Begin Source File
SOURCE=.\Gdi32\MaskBlt.c
# End Source File
# Begin Source File
SOURCE=.\Gdi32\Orhpans.cpp
# End Source File
# Begin Source File
@ -485,6 +489,10 @@ SOURCE=.\Advapi32\RegOpenCurrentUser.c
# End Source File
# Begin Source File
SOURCE=.\Advapi32\RegSetValueExA_fix.c
# End Source File
# Begin Source File
SOURCE=.\Advapi32\RtlGenRandom.c
# End Source File
# Begin Source File
@ -592,8 +600,8 @@ ProjDir=.
InputPath=.\dirlist
"&" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
if not exist $(WkspDir)\util\prep\Release\prep.exe goto error
$(WkspDir)\util\prep\Release\prep.exe "$(ProjDir)"
if not exist "$(WkspDir)\util\prep\Release\prep.exe" goto error
"$(WkspDir)\util\prep\Release\prep.exe" "$(ProjDir)"
goto quit
:error
echo Error - compile PREP (Release) project first
@ -610,8 +618,8 @@ ProjDir=.
InputPath=.\dirlist
"&" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
if not exist $(WkspDir)\util\prep\Release\prep.exe goto error
$(WkspDir)\util\prep\Release\prep.exe "$(ProjDir)"
if not exist "$(WkspDir)\util\prep\Release\prep.exe" goto error
"$(WkspDir)\util\prep\Release\prep.exe" "$(ProjDir)"
goto quit
:error
echo Error - compile PREP (Release) project first
@ -635,11 +643,21 @@ WkspDir=.
InputPath=.\kexbases.def
"$(OutDir)\k32ord.lib" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
cl /nologo /c /TC /DK32ORD_IMPLIB /Fo$(OutDir)\k32ord.obj "$(WkspDir)\common\k32ord.h"
link /DLL /NOENTRY /NOLOGO /IGNORE:4070 /MACHINE:IX86 /DEF:"$(WkspDir)\common\k32ord.def" /OUT:$(OutDir)\k32ord.dll /IMPLIB:$(OutDir)\k32ord.lib $(OutDir)\k32ord.obj
del $(OutDir)\k32ord.exp
del $(OutDir)\k32ord.obj
del $(OutDir)\k32ord.dll
echo /nologo /c /TC /DK32ORD_IMPLIB >"%TEMP%\resp1455.tmp"
echo /Fo"$(OutDir)\k32ord.obj" >>"%TEMP%\resp1455.tmp"
echo "$(WkspDir)\common\k32ord.h" >>"%TEMP%\resp1455.tmp"
cl @"%TEMP%\resp1455.tmp"
del "%TEMP%\resp1455.tmp" >NUL
echo /DLL /NOENTRY /NOLOGO /IGNORE:4070 /MACHINE:IX86 >"%TEMP%\resp1456.tmp"
echo /DEF:"$(WkspDir)\common\k32ord.def" >>"%TEMP%\resp1456.tmp"
echo /OUT:"$(OutDir)\k32ord.dll" >>"%TEMP%\resp1456.tmp"
echo /IMPLIB:"$(OutDir)\k32ord.lib" >>"%TEMP%\resp1456.tmp"
echo "$(OutDir)\k32ord.obj" >>"%TEMP%\resp1456.tmp"
link @"%TEMP%\resp1456.tmp"
del "%TEMP%\resp1456.tmp" >NUL
del "$(OutDir)\k32ord.exp" >NUL
del "$(OutDir)\k32ord.obj" >NUL
del "$(OutDir)\k32ord.dll" >NUL
# End Custom Build
@ -651,11 +669,21 @@ WkspDir=.
InputPath=.\kexbases.def
"$(OutDir)\k32ord.lib" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
cl /nologo /c /TC /DK32ORD_IMPLIB /Fo$(OutDir)\k32ord.obj "$(WkspDir)\common\k32ord.h"
link /DLL /NOENTRY /NOLOGO /IGNORE:4070 /MACHINE:IX86 /DEF:"$(WkspDir)\common\k32ord.def" /OUT:$(OutDir)\k32ord.dll /IMPLIB:$(OutDir)\k32ord.lib $(OutDir)\k32ord.obj
del $(OutDir)\k32ord.exp
del $(OutDir)\k32ord.obj
del $(OutDir)\k32ord.dll
echo /nologo /c /TC /DK32ORD_IMPLIB >"%TEMP%\resp1455.tmp"
echo /Fo"$(OutDir)\k32ord.obj" >>"%TEMP%\resp1455.tmp"
echo "$(WkspDir)\common\k32ord.h" >>"%TEMP%\resp1455.tmp"
cl @"%TEMP%\resp1455.tmp"
del "%TEMP%\resp1455.tmp" >NUL
echo /DLL /NOENTRY /NOLOGO /IGNORE:4070 /MACHINE:IX86 >"%TEMP%\resp1456.tmp"
echo /DEF:"$(WkspDir)\common\k32ord.def" >>"%TEMP%\resp1456.tmp"
echo /OUT:"$(OutDir)\k32ord.dll" >>"%TEMP%\resp1456.tmp"
echo /IMPLIB:"$(OutDir)\k32ord.lib" >>"%TEMP%\resp1456.tmp"
echo "$(OutDir)\k32ord.obj" >>"%TEMP%\resp1456.tmp"
link @"%TEMP%\resp1456.tmp"
del "%TEMP%\resp1456.tmp" >NUL
del "$(OutDir)\k32ord.exp" >NUL
del "$(OutDir)\k32ord.obj" >NUL
del "$(OutDir)\k32ord.dll" >NUL
# End Custom Build