mirror of
https://github.com/reactos/reactos.git
synced 2025-04-06 05:34:22 +00:00
fix some kernel32 module winetests (GetProcAddress, GetModuleFileName)
svn path=/trunk/; revision=36178
This commit is contained in:
parent
beb218924d
commit
f6c0c19edb
1 changed files with 38 additions and 35 deletions
|
@ -230,24 +230,31 @@ GetProcAddress( HMODULE hModule, LPCSTR lpProcName )
|
|||
{
|
||||
ANSI_STRING ProcedureName;
|
||||
FARPROC fnExp = NULL;
|
||||
NTSTATUS Status;
|
||||
|
||||
if (HIWORD(lpProcName) != 0)
|
||||
{
|
||||
RtlInitAnsiString (&ProcedureName,
|
||||
(LPSTR)lpProcName);
|
||||
LdrGetProcedureAddress ((PVOID)hModule,
|
||||
Status = LdrGetProcedureAddress ((PVOID)hModule,
|
||||
&ProcedureName,
|
||||
0,
|
||||
(PVOID*)&fnExp);
|
||||
}
|
||||
else
|
||||
{
|
||||
LdrGetProcedureAddress ((PVOID)hModule,
|
||||
Status = LdrGetProcedureAddress ((PVOID)hModule,
|
||||
NULL,
|
||||
(ULONG)lpProcName,
|
||||
(PVOID*)&fnExp);
|
||||
}
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||
fnExp = NULL;
|
||||
}
|
||||
|
||||
return fnExp;
|
||||
}
|
||||
|
||||
|
@ -313,27 +320,25 @@ GetModuleFileNameA (
|
|||
Module = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
|
||||
if (Module->DllBase == (PVOID)hModule)
|
||||
{
|
||||
if (nSize * sizeof(WCHAR) < Module->FullDllName.Length)
|
||||
{
|
||||
SetLastErrorByStatus (STATUS_BUFFER_TOO_SMALL);
|
||||
}
|
||||
else
|
||||
{
|
||||
FileName.Length = 0;
|
||||
FileName.MaximumLength = (USHORT)nSize * sizeof(WCHAR);
|
||||
FileName.Buffer = lpFilename;
|
||||
Length = min(nSize, Module->FullDllName.Length / sizeof(WCHAR));
|
||||
FileName.Length = 0;
|
||||
FileName.MaximumLength = (USHORT)Length * sizeof(WCHAR);
|
||||
FileName.Buffer = lpFilename;
|
||||
|
||||
/* convert unicode string to ansi (or oem) */
|
||||
if (bIsFileApiAnsi)
|
||||
RtlUnicodeStringToAnsiString (&FileName,
|
||||
&Module->FullDllName,
|
||||
FALSE);
|
||||
else
|
||||
RtlUnicodeStringToOemString (&FileName,
|
||||
&Module->FullDllName,
|
||||
FALSE);
|
||||
Length = Module->FullDllName.Length / sizeof(WCHAR);
|
||||
}
|
||||
/* convert unicode string to ansi (or oem) */
|
||||
if (bIsFileApiAnsi)
|
||||
RtlUnicodeStringToAnsiString (&FileName,
|
||||
&Module->FullDllName,
|
||||
FALSE);
|
||||
else
|
||||
RtlUnicodeStringToOemString (&FileName,
|
||||
&Module->FullDllName,
|
||||
FALSE);
|
||||
|
||||
if (nSize < Length)
|
||||
SetLastErrorByStatus (STATUS_BUFFER_TOO_SMALL);
|
||||
else
|
||||
lpFilename[Length] = '\0';
|
||||
|
||||
RtlLeaveCriticalSection (Peb->LoaderLock);
|
||||
return Length;
|
||||
|
@ -381,22 +386,20 @@ GetModuleFileNameW (
|
|||
|
||||
if (Module->DllBase == (PVOID)hModule)
|
||||
{
|
||||
if (nSize * sizeof(WCHAR) < Module->FullDllName.Length)
|
||||
{
|
||||
SetLastErrorByStatus (STATUS_BUFFER_TOO_SMALL);
|
||||
}
|
||||
else
|
||||
{
|
||||
FileName.Length = 0;
|
||||
FileName.MaximumLength =(USHORT)nSize * sizeof(WCHAR);
|
||||
FileName.Buffer = lpFilename;
|
||||
Length = min(nSize, Module->FullDllName.Length / sizeof(WCHAR));
|
||||
FileName.Length = 0;
|
||||
FileName.MaximumLength = (USHORT) Length * sizeof(WCHAR);
|
||||
FileName.Buffer = lpFilename;
|
||||
|
||||
RtlCopyUnicodeString (&FileName,
|
||||
&Module->FullDllName);
|
||||
Length = Module->FullDllName.Length / sizeof(WCHAR);
|
||||
}
|
||||
RtlCopyUnicodeString (&FileName,
|
||||
&Module->FullDllName);
|
||||
if (nSize < Length)
|
||||
SetLastErrorByStatus (STATUS_BUFFER_TOO_SMALL);
|
||||
else
|
||||
lpFilename[Length] = L'\0';
|
||||
|
||||
RtlLeaveCriticalSection (Peb->LoaderLock);
|
||||
|
||||
return Length;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue