win7编程接口的一些变化

原文链接:http://www.nirsoft.net/articles/windows_7_kernel_architecture_changes.html

Windows 7 introduces a new set of dll files containing exported functions of many well-known WIN32 APIs. All these filenames begins with 'api-ms-win-core' prefix, followed by the functions category name. 
For example, api-ms-win-core-localregistry-l1-1-0.dll contains the exported names for all Registry functions, api-ms-win-core-file-l1-1-0.dll contains the exported names for all file-related functions, api-ms-win-core-localization-l1-1-0.dll contains the exported names for all localization functions, and so on.

    If you look deeply into these files, you'll see that all these files are very small, and the functions in them doen't do anything, and simply returns a 'TRUE' value. Just for example, here's the assembly language content of RegDeleteValueW function in api-ms-win-core-localregistry-l1-1-0.dll:

084010CE 33C0                    xor eax, eax
084010D0 40                      inc eax
084010D1 C20800                  ret 0008
By looking in dependency walker utility, we can see that advapi32.dll, kernel32.dll, and other system dll files, are now statically linked to these empty api-ms-win-core files.

    Moreover, if we look in the assembly language output of many API functions, we can see that they simply call their corresponding function in one of these api-ms-win-core Dlls. Just for example, RegDeleteValueW in advapi32.dll, simply contains a jump to the RegDeleteValueW in API-MS-Win-Core-LocalRegistry-L1-1-0.dll:

ADVAPI32!RegDeleteValueW:
77C6F301 8BFF                    mov edi, edi
77C6F303 55                      push ebp
77C6F304 8BEC                    mov ebp, esp
77C6F306 5D                      pop ebp
77C6F307 EB05                    jmp 77C6F30E
.
.
.
77C6F30E FF25B414C677            Jmp dword ptr [77C614B4]   <-- [77C614B4] Points the import entry 
of API-MS-Win-Core-LocalRegistry-L1-1-0.RegDeleteValueW
    So if RegDeleteValueW in ADVAPI32 and other functions simply jumps to empty functions, how is it possible that these functions still works properly ?

    The answer is pretty simple: When Windows loads the dll files, all the import entries of these api-ms-win-core Dlls are replaced with a call to a real function in Windows kernel. 
    So here's our RegDeleteValueW example again: when loading a program into WinDbg, we can see that the jmp call now points to kernel32!RegDeleteValueW function. That's because during the loading of advapi32.dll, Windows automatically replace the import entry of API-MS-Win-Core-LocalRegistry-L1-1-0.RegDeleteValueW to the function address of RegDeleteValueW in kernel32.

75e5f301 8bff            mov     edi,edi
75e5f303 55              push    ebp
75e5f304 8bec            mov     ebp,esp
75e5f306 5d              pop     ebp
75e5f307 eb05            jmp     ADVAPI32!RegDeleteValueW+0xd (75e5f30e)
.
.
.
75e5f30e ff25b414e575    jmp     dword ptr [ADVAPI32+0x14b4 (75e514b4)] ds:0023:75e514b4=
{kernel32!RegDeleteValueW (758bd5af)}

 

 

Another new dll: kernelbase.dll
 In addition to the new API-MS-Win-Core dll files, there is also another new dll: kernelbase.dll 
In previous versions of Windows, most of the kernel32 functions called to their corresponding functions in ntdll.dll. 
In Windows 7, most of the kernel functions call to their corresponding functions in kernelbase.dll, and the kernelbase dll is the one that makes the calls to ntdll.dll

 

Effects on existing applications - compatibility issues.
Most of the existing applications should not be affected by this kernel change, because all standard API calls still works the same as in previous versions of Windows. 
However, there are some diagnostic/debugging applications that rely on the calls chain inside the Windows kernel. These kind of applications may not work properly in Windows 7. 
My own utilities,  RegFromApp and  ProcessActivityView failed to work under Windows 7 because of these changes, and that what led me to discover the kernel changes of Windows 7. These utilities problems already fixed and now they works properly in Windows 7.

 

API-MS-Win-Core List
Finally, here's the list of all core dll files added to Windows 7 and the functions list that each one of them contain. I used my own DLL Export Viewer utility to generate the list.

 

DLL FileFunction Names
api-ms-win-core-console-l1-1-0.dll
AllocConsoleGetConsoleCPGetConsoleMode
GetConsoleOutputCPGetNumberOfConsoleInputEventsPeekConsoleInputA
ReadConsoleAReadConsoleInputAReadConsoleInputW
ReadConsoleWSetConsoleCtrlHandlerSetConsoleMode
WriteConsoleAWriteConsoleW
api-ms-win-core-datetime-l1-1-0.dll
GetDateFormatAGetDateFormatWGetTimeFormatA
GetTimeFormatW
api-ms-win-core-debug-l1-1-0.dll
DebugBreakIsDebuggerPresentOutputDebugStringA
OutputDebugStringW
api-ms-win-core-delayload-l1-1-0.dll
DelayLoadFailureHook
api-ms-win-core-errorhandling-l1-1-0.dll
GetErrorModeGetLastErrorRaiseException
SetErrorModeSetLastErrorSetUnhandledExceptionFilter
UnhandledExceptionFilter
api-ms-win-core-fibers-l1-1-0.dll
FlsAllocFlsFreeFlsGetValue
FlsSetValue
api-ms-win-core-file-l1-1-0.dll
CompareFileTimeCreateDirectoryACreateDirectoryW
CreateFileACreateFileWDefineDosDeviceW
DeleteFileADeleteFileWDeleteVolumeMountPointW
FileTimeToLocalFileTimeFileTimeToSystemTimeFindClose
FindCloseChangeNotificationFindFirstChangeNotificationAFindFirstChangeNotificationW
FindFirstFileAFindFirstFileExAFindFirstFileExW
FindFirstFileWFindFirstVolumeWFindNextChangeNotification
FindNextFileAFindNextFileWFindNextVolumeW
FindVolumeCloseFlushFileBuffersGetDiskFreeSpaceA
GetDiskFreeSpaceExAGetDiskFreeSpaceExWGetDiskFreeSpaceW
GetDriveTypeAGetDriveTypeWGetFileAttributesA
GetFileAttributesExAGetFileAttributesExWGetFileAttributesW
GetFileInformationByHandleGetFileSizeGetFileSizeEx
GetFileTimeGetFileTypeGetFinalPathNameByHandleA
GetFinalPathNameByHandleWGetFullPathNameAGetFullPathNameW
GetLogicalDrivesGetLogicalDriveStringsWGetLongPathNameA
GetLongPathNameWGetShortPathNameWGetTempFileNameW
GetVolumeInformationByHandleWGetVolumeInformationWGetVolumePathNameW
LocalFileTimeToFileTimeLockFileLockFileEx
QueryDosDeviceWReadFileReadFileEx
ReadFileScatterRemoveDirectoryARemoveDirectoryW
SetEndOfFileSetFileAttributesASetFileAttributesW
SetFileInformationByHandleSetFilePointerSetFilePointerEx
SetFileTimeSetFileValidDataUnlockFile
UnlockFileExWriteFileWriteFileEx
WriteFileGather
api-ms-win-core-handle-l1-1-0.dll
CloseHandleDuplicateHandleGetHandleInformation
SetHandleInformation
api-ms-win-core-heap-l1-1-0.dll
GetProcessHeapGetProcessHeapsHeapAlloc
HeapCompactHeapCreateHeapDestroy
HeapFreeHeapLockHeapQueryInformation
HeapReAllocHeapSetInformationHeapSize
HeapSummaryHeapUnlockHeapValidate
HeapWalk
api-ms-win-core-interlocked-l1-1-0.dll
InitializeSListHeadInterlockedCompareExchangeInterlockedCompareExchange64
InterlockedDecrementInterlockedExchangeInterlockedExchangeAdd
InterlockedFlushSListInterlockedIncrementInterlockedPopEntrySList
InterlockedPushEntrySListInterlockedPushListSListQueryDepthSList
api-ms-win-core-io-l1-1-0.dll
CancelIoExCreateIoCompletionPortDeviceIoControl
GetOverlappedResultGetQueuedCompletionStatusGetQueuedCompletionStatusEx
PostQueuedCompletionStatus
api-ms-win-core-libraryloader-l1-1-0.dll
DisableThreadLibraryCallsFindResourceExWFindStringOrdinal
FreeLibraryFreeLibraryAndExitThreadFreeResource
GetModuleFileNameAGetModuleFileNameWGetModuleHandleA
GetModuleHandleExAGetModuleHandleExWGetModuleHandleW
GetProcAddressLoadLibraryExALoadLibraryExW
LoadResourceLoadStringALoadStringW
LockResourceSizeofResource
api-ms-win-core-localization-l1-1-0.dll
ConvertDefaultLocaleFindNLSStringFindNLSStringEx
GetACPGetCalendarInfoExGetCalendarInfoW
GetCPFileNameFromRegistryGetCPInfoGetCPInfoExW
GetFileMUIInfoGetFileMUIPathGetLocaleInfoEx
GetLocaleInfoWGetNLSVersionGetNLSVersionEx
GetOEMCPGetProcessPreferredUILanguagesGetSystemDefaultLangID
GetSystemDefaultLCIDGetSystemPreferredUILanguagesGetThreadLocale
GetThreadPreferredUILanguagesGetThreadUILanguageGetUILanguageInfo
GetUserDefaultLangIDGetUserDefaultLCIDGetUserPreferredUILanguages
IsNLSDefinedStringIsValidCodePageIsValidLanguageGroup
IsValidLocaleIsValidLocaleNameLCMapStringEx
LCMapStringWLocaleNameToLCIDNlsCheckPolicy
NlsEventDataDescCreateNlsGetCacheUpdateCountNlsUpdateLocale
NlsUpdateSystemLocaleNlsWriteEtwEventResolveLocaleName
SetCalendarInfoWSetLocaleInfoWSetThreadLocale
VerLanguageNameAVerLanguageNameW
api-ms-win-core-localregistry-l1-1-0.dll
RegCloseKeyRegCreateKeyExARegCreateKeyExW
RegDeleteKeyExARegDeleteKeyExWRegDeleteTreeA
RegDeleteTreeWRegDeleteValueARegDeleteValueW
RegDisablePredefinedCacheExRegEnumKeyExARegEnumKeyExW
RegEnumValueARegEnumValueWRegFlushKey
RegGetKeySecurityRegGetValueARegGetValueW
RegLoadKeyARegLoadKeyWRegLoadMUIStringA
RegLoadMUIStringWRegNotifyChangeKeyValueRegOpenCurrentUser
RegOpenKeyExARegOpenKeyExWRegOpenUserClassesRoot
RegQueryInfoKeyARegQueryInfoKeyWRegQueryValueExA
RegQueryValueExWRegRestoreKeyARegRestoreKeyW
RegSaveKeyExARegSaveKeyExWRegSetKeySecurity
RegSetValueExARegSetValueExWRegUnLoadKeyA
RegUnLoadKeyW
api-ms-win-core-memory-l1-1-0.dll
CreateFileMappingWFlushViewOfFileMapViewOfFile
MapViewOfFileExOpenFileMappingWReadProcessMemory
UnmapViewOfFileVirtualAllocVirtualAllocEx
VirtualFreeVirtualFreeExVirtualProtect
VirtualProtectExVirtualQueryVirtualQueryEx
WriteProcessMemory
api-ms-win-core-misc-l1-1-0.dll
EnumSystemLocalesAFatalAppExitAFatalAppExitW
FormatMessageAFormatMessageWGlobalAlloc
GlobalFreeIsProcessInJobIsWow64Process
LCMapStringALocalAllocLocalFree
LocalLockLocalReAllocLocalUnlock
lstrcmplstrcmpAlstrcmpi
lstrcmpiAlstrcmpiWlstrcmpW
lstrcpynlstrcpynAlstrcpynW
lstrlenlstrlenAlstrlenW
NeedCurrentDirectoryForExePathANeedCurrentDirectoryForExePathWPulseEvent
SetHandleCountSleepWow64DisableWow64FsRedirection
Wow64RevertWow64FsRedirection
api-ms-win-core-namedpipe-l1-1-0.dll
ConnectNamedPipeCreateNamedPipeWCreatePipe
DisconnectNamedPipeGetNamedPipeAttributeGetNamedPipeClientComputerNameW
ImpersonateNamedPipeClientPeekNamedPipeSetNamedPipeHandleState
TransactNamedPipeWaitNamedPipeW
api-ms-win-core-processenvironment-l1-1-0.dll
ExpandEnvironmentStringsAExpandEnvironmentStringsWFreeEnvironmentStringsA
FreeEnvironmentStringsWGetCommandLineAGetCommandLineW
GetCurrentDirectoryAGetCurrentDirectoryWGetEnvironmentStrings
GetEnvironmentStringsAGetEnvironmentStringsWGetEnvironmentVariableA
GetEnvironmentVariableWGetStdHandleSearchPathW
SetCurrentDirectoryASetCurrentDirectoryWSetEnvironmentStringsW
SetEnvironmentVariableASetEnvironmentVariableWSetStdHandle
SetStdHandleEx
api-ms-win-core-processthreads-l1-1-0.dll
CreateProcessACreateProcessAsUserWCreateProcessW
CreateRemoteThreadCreateRemoteThreadExCreateThread
DeleteProcThreadAttributeListExitProcessExitThread
FlushProcessWriteBuffersGetCurrentProcessGetCurrentProcessId
GetCurrentThreadGetCurrentThreadIdGetExitCodeProcess
GetExitCodeThreadGetPriorityClassGetProcessId
GetProcessIdOfThreadGetProcessTimesGetProcessVersion
GetStartupInfoWGetThreadIdGetThreadPriority
GetThreadPriorityBoostInitializeProcThreadAttributeListOpenProcessToken
OpenThreadOpenThreadTokenProcessIdToSessionId
QueryProcessAffinityUpdateModeQueueUserAPCResumeThread
SetPriorityClassSetProcessAffinityUpdateModeSetProcessShutdownParameters
SetThreadPrioritySetThreadPriorityBoostSetThreadStackGuarantee
SetThreadTokenSuspendThreadSwitchToThread
TerminateProcessTerminateThreadTlsAlloc
TlsFreeTlsGetValueTlsSetValue
UpdateProcThreadAttribute
api-ms-win-core-profile-l1-1-0.dll
QueryPerformanceCounterQueryPerformanceFrequency
api-ms-win-core-rtlsupport-l1-1-0.dll
RtlCaptureContextRtlCaptureStackBackTraceRtlFillMemory
RtlUnwind
api-ms-win-core-string-l1-1-0.dll
CompareStringExCompareStringOrdinalCompareStringW
FoldStringWGetStringTypeExWGetStringTypeW
MultiByteToWideCharWideCharToMultiByte
api-ms-win-core-synch-l1-1-0.dll
AcquireSRWLockExclusiveAcquireSRWLockShared
CancelWaitableTimerCreateEventA
CreateEventExACreateEventExW
CreateEventWCreateMutexA
CreateMutexExACreateMutexExW
CreateMutexWCreateSemaphoreExW
CreateWaitableTimerExWDeleteCriticalSection
EnterCriticalSectionInitializeCriticalSection
InitializeCriticalSectionAndSpinCountInitializeCriticalSectionEx
InitializeSRWLockLeaveCriticalSection
OpenEventAOpenEventW
OpenMutexWOpenProcess
OpenSemaphoreWOpenWaitableTimerW
ReleaseMutexReleaseSemaphore
ReleaseSRWLockExclusiveReleaseSRWLockShared
ResetEventSetCriticalSectionSpinCount
SetEventSetWaitableTimer
SetWaitableTimerExSleepEx
TryAcquireSRWLockExclusiveTryAcquireSRWLockShared
TryEnterCriticalSectionWaitForMultipleObjectsEx
WaitForSingleObjectWaitForSingleObjectEx
api-ms-win-core-sysinfo-l1-1-0.dll
GetComputerNameExAGetComputerNameExWGetDynamicTimeZoneInformation
GetLocalTimeGetLogicalProcessorInformationGetLogicalProcessorInformationEx
GetSystemDirectoryAGetSystemDirectoryWGetSystemInfo
GetSystemTimeGetSystemTimeAdjustmentGetSystemTimeAsFileTime
GetSystemWindowsDirectoryAGetSystemWindowsDirectoryWGetTickCount
GetTickCount64GetTimeZoneInformationGetTimeZoneInformationForYear
GetVersionGetVersionExAGetVersionExW
GetWindowsDirectoryAGetWindowsDirectoryWGlobalMemoryStatusEx
SetLocalTimeSystemTimeToFileTimeSystemTimeToTzSpecificLocalTime
TzSpecificLocalTimeToSystemTime
api-ms-win-core-threadpool-l1-1-0.dll
CallbackMayRunLongCancelThreadpoolIo
ChangeTimerQueueTimerCloseThreadpool
CloseThreadpoolCleanupGroupCloseThreadpoolCleanupGroupMembers
CloseThreadpoolIoCloseThreadpoolTimer
CloseThreadpoolWaitCloseThreadpoolWork
CreateThreadpoolCreateThreadpoolCleanupGroup
CreateThreadpoolIoCreateThreadpoolTimer
CreateThreadpoolWaitCreateThreadpoolWork
CreateTimerQueueCreateTimerQueueTimer
DeleteTimerQueueExDeleteTimerQueueTimer
DisassociateCurrentThreadFromCallbackFreeLibraryWhenCallbackReturns
IsThreadpoolTimerSetLeaveCriticalSectionWhenCallbackReturns
QueryThreadpoolStackInformationRegisterWaitForSingleObjectEx
ReleaseMutexWhenCallbackReturnsReleaseSemaphoreWhenCallbackReturns
SetEventWhenCallbackReturnsSetThreadpoolStackInformation
SetThreadpoolThreadMaximumSetThreadpoolThreadMinimum
SetThreadpoolTimerSetThreadpoolWait
StartThreadpoolIoSubmitThreadpoolWork
TrySubmitThreadpoolCallbackUnregisterWaitEx
WaitForThreadpoolIoCallbacksWaitForThreadpoolTimerCallbacks
WaitForThreadpoolWaitCallbacksWaitForThreadpoolWorkCallbacks
api-ms-win-core-util-l1-1-0.dll
BeepDecodePointerDecodeSystemPointer
EncodePointerEncodeSystemPointer
api-ms-win-core-xstate-l1-1-0.dll
RtlCopyExtendedContextRtlGetEnabledExtendedFeaturesRtlGetExtendedContextLength
RtlGetExtendedFeaturesMaskRtlInitializeExtendedContextRtlLocateExtendedFeature
RtlLocateLegacyContextRtlSetExtendedFeaturesMask
api-ms-win-security-base-l1-1-0.dll
AccessCheckAccessCheckAndAuditAlarmW
AccessCheckByTypeAccessCheckByTypeAndAuditAlarmW
AccessCheckByTypeResultListAccessCheckByTypeResultListAndAuditAlarmByHandleW
AccessCheckByTypeResultListAndAuditAlarmWAddAccessAllowedAce
AddAccessAllowedAceExAddAccessAllowedObjectAce
AddAccessDeniedAceAddAccessDeniedAceEx
AddAccessDeniedObjectAceAddAce
AddAuditAccessAceAddAuditAccessAceEx
AddAuditAccessObjectAceAddMandatoryAce
AdjustTokenGroupsAdjustTokenPrivileges
AllocateAndInitializeSidAllocateLocallyUniqueId
AreAllAccessesGrantedAreAnyAccessesGranted
CheckTokenMembershipConvertToAutoInheritPrivateObjectSecurity
CopySidCreatePrivateObjectSecurity
CreatePrivateObjectSecurityExCreatePrivateObjectSecurityWithMultipleInheritance
CreateRestrictedTokenCreateWellKnownSid
DeleteAceDestroyPrivateObjectSecurity
DuplicateTokenDuplicateTokenEx
EqualDomainSidEqualPrefixSid
EqualSidFindFirstFreeAce
FreeSidGetAce
GetAclInformationGetFileSecurityW
GetKernelObjectSecurityGetLengthSid
GetPrivateObjectSecurityGetSecurityDescriptorControl
GetSecurityDescriptorDaclGetSecurityDescriptorGroup
GetSecurityDescriptorLengthGetSecurityDescriptorOwner
GetSecurityDescriptorRMControlGetSecurityDescriptorSacl
GetSidIdentifierAuthorityGetSidLengthRequired
GetSidSubAuthorityGetSidSubAuthorityCount
GetTokenInformationGetWindowsAccountDomainSid
ImpersonateAnonymousTokenImpersonateLoggedOnUser
ImpersonateSelfInitializeAcl
InitializeSecurityDescriptorInitializeSid
IsTokenRestrictedIsValidAcl
IsValidRelativeSecurityDescriptorIsValidSecurityDescriptor
IsValidSidIsWellKnownSid
MakeAbsoluteSDMakeAbsoluteSD2
MakeSelfRelativeSDMapGenericMask
ObjectCloseAuditAlarmWObjectDeleteAuditAlarmW
ObjectOpenAuditAlarmWObjectPrivilegeAuditAlarmW
PrivilegeCheckPrivilegedServiceAuditAlarmW
QuerySecurityAccessMaskRevertToSelf
SetAclInformationSetFileSecurityW
SetKernelObjectSecuritySetPrivateObjectSecurity
SetPrivateObjectSecurityExSetSecurityAccessMask
SetSecurityDescriptorControlSetSecurityDescriptorDacl
SetSecurityDescriptorGroupSetSecurityDescriptorOwner
SetSecurityDescriptorRMControlSetSecurityDescriptorSacl
SetTokenInformation
api-ms-win-security-lsalookup-l1-1-0.dll
LookupAccountNameLocalALookupAccountNameLocalWLookupAccountSidLocalA
LookupAccountSidLocalWLsaLookupCloseLsaLookupFreeMemory
LsaLookupGetDomainInfoLsaLookupManageSidNameMappingLsaLookupOpenLocalPolicy
LsaLookupTranslateNamesLsaLookupTranslateSids
api-ms-win-security-sddl-l1-1-0.dll
ConvertSecurityDescriptorToStringSecurityDescriptorWConvertSidToStringSidW
ConvertStringSecurityDescriptorToSecurityDescriptorWConvertStringSidToSidW
api-ms-win-service-core-l1-1-0.dll
RegisterServiceCtrlHandlerExWSetServiceStatusStartServiceCtrlDispatcherW
api-ms-win-service-management-l1-1-0.dll
CloseServiceHandleControlServiceExWCreateServiceW
DeleteServiceOpenSCManagerWOpenServiceW
StartServiceW
api-ms-win-service-management-l2-1-0.dll
ChangeServiceConfig2WChangeServiceConfigWNotifyServiceStatusChangeW
QueryServiceConfig2WQueryServiceConfigWQueryServiceObjectSecurity
QueryServiceStatusExSetServiceObjectSecurity
api-ms-win-service-winsvc-l1-1-0.dll
ChangeServiceConfig2AChangeServiceConfigAControlService
ControlServiceExACreateServiceAI_QueryTagInformation
I_ScBroadcastServiceControlMessageI_ScIsSecurityProcessI_ScPnPGetServiceName
I_ScQueryServiceConfigI_ScRpcBindAI_ScRpcBindW
I_ScSendPnPMessageI_ScSendTSMessageI_ScValidatePnPService
NotifyServiceStatusChangeAOpenSCManagerAOpenServiceA
QueryServiceConfig2AQueryServiceConfigAQueryServiceStatus
RegisterServiceCtrlHandlerARegisterServiceCtrlHandlerExARegisterServiceCtrlHandlerW
StartServiceAStartServiceCtrlDispatcherA

 

 

 
 
0
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值