📄 udynlink.cpp
字号:
goto done;
}
}
done:
// cleanup
Win95_WNetCloseEnum(hEnum);
free(pNetResource);
return fResult;
}
DWORD
UDynLink::Win95_WNetOpenEnum(
DWORD dwScope,
DWORD dwType,
DWORD dwUsage,
LPNETRESOURCE lpNetResource,
LPHANDLE lphEnum)
{
if (IsNull(Win95_WNetOpenEnumAddr))
{
LoadMpr();
#if defined(_UNICODE)
Win95_WNetOpenEnumAddr = reinterpret_cast<Win95_WNetOpenEnumType>(
GetProcAddress(MprHandle, "WNetOpenEnumW"));
#else // !_UNICODE
Win95_WNetOpenEnumAddr = reinterpret_cast<Win95_WNetOpenEnumType>(
GetProcAddress(MprHandle, "WNetOpenEnumA"));
#endif // _UNICODE
if (IsNull(Win95_WNetOpenEnumAddr))
THROW_ERRORS(kPGPError_Win32DllOpFailed, GetLastError());
}
return Win95_WNetOpenEnumAddr(dwScope, dwType, dwUsage, lpNetResource,
lphEnum);
}
VOID
UDynLink::WinNT_FormatEx(
PWCHAR driveRoot,
DWORD mediaFlag,
PWCHAR format,
PWCHAR label,
BOOL quickFormat,
DWORD clusterSize,
PFMIFSCALLBACK callback)
{
if (IsNull(WinNT_FormatExAddr))
{
LoadFmifs();
WinNT_FormatExAddr =
reinterpret_cast<WinNT_FormatExType>(
GetProcAddress(FmifsHandle, "FormatEx"));
if (IsNull(WinNT_FormatExAddr))
THROW_ERRORS(kPGPError_Win32DllOpFailed, GetLastError());
}
WinNT_FormatExAddr(driveRoot, mediaFlag, format, label, quickFormat,
clusterSize, callback);
}
DWORD
UDynLink::WinNT_NetApiBufferFree(LPVOID Buffer)
{
if (IsNull(WinNT_NetApiBufferFreeAddr))
{
LoadNetApi32();
WinNT_NetApiBufferFreeAddr =
reinterpret_cast<WinNT_NetApiBufferFreeType>(
GetProcAddress(NetApi32Handle, "NetApiBufferFree"));
if (IsNull(WinNT_NetApiBufferFreeAddr))
THROW_ERRORS(kPGPError_Win32DllOpFailed, GetLastError());
}
return WinNT_NetApiBufferFreeAddr(Buffer);
}
DWORD
UDynLink::WinNT_NetShareGetInfo(
LPWSTR servername,
LPWSTR netname,
DWORD level,
LPBYTE *bufptr)
{
if (IsNull(WinNT_NetShareGetInfoAddr))
{
LoadNetApi32();
WinNT_NetShareGetInfoAddr = reinterpret_cast<
WinNT_NetShareGetInfoType>(GetProcAddress(NetApi32Handle,
"NetShareGetInfo"));
if (IsNull(WinNT_NetShareGetInfoAddr))
THROW_ERRORS(kPGPError_Win32DllOpFailed, GetLastError());
}
return WinNT_NetShareGetInfoAddr(servername, netname, level, bufptr);
}
DWORD
UDynLink::WinNT_WNetGetUniversalName(
LPCTSTR lpLocalPath,
DWORD dwInfoLevel,
LPVOID lpBuffer,
LPDWORD lpBufferSize)
{
if (IsNull(WinNT_WNetGetUniversalNameAddr))
{
LoadMpr();
#if defined(_UNICODE)
WinNT_WNetGetUniversalNameAddr =
reinterpret_cast<WinNT_WNetGetUniversalNameType>(
GetProcAddress(MprHandle, "WNetGetUniversalNameW"));
#else // !_UNICODE
WinNT_WNetGetUniversalNameAddr =
reinterpret_cast<WinNT_WNetGetUniversalNameType>(
GetProcAddress(MprHandle, "WNetGetUniversalNameA"));
#endif // _UNICODE
if (IsNull(WinNT_WNetGetUniversalNameAddr))
THROW_ERRORS(kPGPError_Win32DllOpFailed, GetLastError());
}
return WinNT_WNetGetUniversalNameAddr(lpLocalPath, dwInfoLevel,
lpBuffer, lpBufferSize);
}
BOOL
UDynLink::WinNT_OpenProcessToken(
HANDLE ProcessHandle,
DWORD DesiredAccess,
PHANDLE TokenHandle)
{
if (IsNull(WinNT_OpenProcessTokenAddr))
{
LoadAdvapi32();
WinNT_OpenProcessTokenAddr =
reinterpret_cast<WinNT_OpenProcessTokenType>(
GetProcAddress(Advapi32Handle, "OpenProcessToken"));
if (IsNull(WinNT_OpenProcessTokenAddr))
THROW_ERRORS(kPGPError_Win32DllOpFailed, GetLastError());
}
return WinNT_OpenProcessTokenAddr(ProcessHandle, DesiredAccess,
TokenHandle);
}
BOOL
UDynLink::WinNT_OpenThreadToken(
HANDLE ThreadHandle,
DWORD DesiredAccess,
BOOL OpenAsSelf,
PHANDLE TokenHandle)
{
if (IsNull(WinNT_OpenThreadTokenAddr))
{
LoadAdvapi32();
WinNT_OpenThreadTokenAddr =
reinterpret_cast<WinNT_OpenThreadTokenType>(
GetProcAddress(Advapi32Handle, "OpenThreadToken"));
if (IsNull(WinNT_OpenThreadTokenAddr))
THROW_ERRORS(kPGPError_Win32DllOpFailed, GetLastError());
}
return WinNT_OpenThreadTokenAddr(ThreadHandle, DesiredAccess,
OpenAsSelf, TokenHandle);
}
BOOL
UDynLink::WinNT_GetTokenInformation(
HANDLE TokenHandle,
TOKEN_INFORMATION_CLASS TokenInformationClass,
LPVOID TokenInformation,
DWORD TokenInformationLength,
PDWORD ReturnLength)
{
if (IsNull(WinNT_GetTokenInformationAddr))
{
LoadAdvapi32();
WinNT_GetTokenInformationAddr =
reinterpret_cast<WinNT_GetTokenInformationType>(
GetProcAddress(Advapi32Handle, "GetTokenInformation"));
if (IsNull(WinNT_GetTokenInformationAddr))
THROW_ERRORS(kPGPError_Win32DllOpFailed, GetLastError());
}
return WinNT_GetTokenInformationAddr(TokenHandle, TokenInformationClass,
TokenInformation, TokenInformationLength, ReturnLength);
}
BOOL
UDynLink::WinNT_AllocateAndInitializeSid(
PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
BYTE nSubAuthorityCount,
DWORD nSubAuthority0,
DWORD nSubAuthority1,
DWORD nSubAuthority2,
DWORD nSubAuthority3,
DWORD nSubAuthority4,
DWORD nSubAuthority5,
DWORD nSubAuthority6,
DWORD nSubAuthority7,
PSID *pSid)
{
if (IsNull(WinNT_AllocateAndInitializeSidAddr))
{
LoadAdvapi32();
WinNT_AllocateAndInitializeSidAddr =
reinterpret_cast<WinNT_AllocateAndInitializeSidType>(
GetProcAddress(Advapi32Handle, "AllocateAndInitializeSid"));
if (IsNull(WinNT_AllocateAndInitializeSidAddr))
THROW_ERRORS(kPGPError_Win32DllOpFailed, GetLastError());
}
return WinNT_AllocateAndInitializeSidAddr(pIdentifierAuthority,
nSubAuthorityCount, nSubAuthority0, nSubAuthority1, nSubAuthority2,
nSubAuthority3, nSubAuthority4, nSubAuthority5, nSubAuthority6,
nSubAuthority7, pSid);
}
BOOL
UDynLink::WinNT_EqualSid(PSID pSid1, PSID pSid2)
{
if (IsNull(WinNT_EqualSidAddr))
{
LoadAdvapi32();
WinNT_EqualSidAddr =
reinterpret_cast<WinNT_EqualSidType>(
GetProcAddress(Advapi32Handle, "EqualSid"));
if (IsNull(WinNT_EqualSidAddr))
THROW_ERRORS(kPGPError_Win32DllOpFailed, GetLastError());
}
return WinNT_EqualSidAddr(pSid1, pSid2);
}
PVOID
UDynLink::WinNT_FreeSid(PSID pSid)
{
if (IsNull(WinNT_FreeSidAddr))
{
LoadAdvapi32();
WinNT_FreeSidAddr =
reinterpret_cast<WinNT_FreeSidType>(
GetProcAddress(Advapi32Handle, "FreeSid"));
if (IsNull(WinNT_FreeSidAddr))
THROW_ERRORS(kPGPError_Win32DllOpFailed, GetLastError());
}
return WinNT_FreeSidAddr(pSid);
}
BOOL
UDynLink::Win2k_GetVolumeNameForVolumeMountPoint(
LPCTSTR lpszVolumeMountPoint,
LPTSTR lpszVolumeName,
DWORD cchBufferLength)
{
if (IsNull(Win2k_GetVolumeNameForVolumeMountPointAddr))
{
LoadKernel32();
#if defined(_UNICODE)
Win2k_GetVolumeNameForVolumeMountPointAddr =
reinterpret_cast<Win2k_GetVolumeNameForVolumeMountPointType>(
GetProcAddress(Kernel32Handle,
"GetVolumeNameForVolumeMountPointW"));
#else // !_UNICODE
Win2k_GetVolumeNameForVolumeMountPointAddr =
reinterpret_cast<Win2k_GetVolumeNameForVolumeMountPointType>(
GetProcAddress(Kernel32Handle,
"GetVolumeNameForVolumeMountPointA"));
#endif // _UNICODE
if (IsNull(Win2k_GetVolumeNameForVolumeMountPointAddr))
THROW_ERRORS(kPGPError_Win32DllOpFailed, GetLastError());
}
return Win2k_GetVolumeNameForVolumeMountPointAddr(lpszVolumeMountPoint,
lpszVolumeName, cchBufferLength);
}
BOOL
UDynLink::Win2k_GetVolumePathName(
LPCTSTR lpszFileName,
LPTSTR lpszVolumePathName,
DWORD cchBufferLength)
{
if (IsNull(Win2k_GetVolumePathNameAddr))
{
LoadKernel32();
#if defined(_UNICODE)
Win2k_GetVolumePathNameAddr =
reinterpret_cast<Win2k_GetVolumePathNameType>(
GetProcAddress(Kernel32Handle, "GetVolumePathNameW"));
#else // !_UNICODE
Win2k_GetVolumePathNameAddr =
reinterpret_cast<Win2k_GetVolumePathNameType>(
GetProcAddress(Kernel32Handle, "GetVolumePathNameA"));
#endif // _UNICODE
if (IsNull(Win2k_GetVolumePathNameAddr))
THROW_ERRORS(kPGPError_Win32DllOpFailed, GetLastError());
}
return Win2k_GetVolumePathNameAddr(lpszFileName, lpszVolumePathName,
cchBufferLength);
}
BOOL
UDynLink::Win2k_SetVolumeMountPoint(
LPCTSTR lpszVolumeMountPoint,
LPCTSTR lpszVolumeName)
{
if (IsNull(Win2k_SetVolumeMountPointAddr))
{
LoadKernel32();
#if defined(_UNICODE)
Win2k_SetVolumeMountPointAddr =
reinterpret_cast<Win2k_SetVolumeMountPointType>(
GetProcAddress(Kernel32Handle, "SetVolumeMountPointW"));
#else // !_UNICODE
Win2k_SetVolumeMountPointAddr =
reinterpret_cast<Win2k_SetVolumeMountPointType>(
GetProcAddress(Kernel32Handle, "SetVolumeMountPointA"));
#endif // _UNICODE
if (IsNull(Win2k_SetVolumeMountPointAddr))
THROW_ERRORS(kPGPError_Win32DllOpFailed, GetLastError());
}
return Win2k_SetVolumeMountPointAddr(lpszVolumeMountPoint,
lpszVolumeName);
}
BOOL
UDynLink::Win2k_DeleteVolumeMountPoint(LPCTSTR lpszVolumeMountPoint)
{
if (IsNull(Win2k_DeleteVolumeMountPointAddr))
{
LoadKernel32();
#if defined(_UNICODE)
Win2k_DeleteVolumeMountPointAddr =
reinterpret_cast<Win2k_DeleteVolumeMountPointType>(
GetProcAddress(Kernel32Handle, "DeleteVolumeMountPointW"));
#else // !_UNICODE
Win2k_DeleteVolumeMountPointAddr =
reinterpret_cast<Win2k_DeleteVolumeMountPointType>(
GetProcAddress(Kernel32Handle, "DeleteVolumeMountPointA"));
#endif // _UNICODE
if (IsNull(Win2k_DeleteVolumeMountPointAddr))
THROW_ERRORS(kPGPError_Win32DllOpFailed, GetLastError());
}
return Win2k_DeleteVolumeMountPointAddr(lpszVolumeMountPoint);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -