コード例 #1
0
ファイル: timezone.c プロジェクト: GYGit/reactos
/*
 * @implemented
 */
BOOL
WINAPI
SetTimeZoneInformation(CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation)
{
    NTSTATUS Status;

    DPRINT("SetTimeZoneInformation()\n");

    Status = RtlSetTimeZoneInformation((LPTIME_ZONE_INFORMATION)lpTimeZoneInformation);
    if (!NT_SUCCESS(Status))
    {
        DPRINT1("RtlSetTimeZoneInformation() failed (Status %lx)\n", Status);
        BaseSetLastNTError(Status);
        return FALSE;
    }

    Status = NtSetSystemInformation(SystemCurrentTimeZoneInformation,
                                    (PVOID)lpTimeZoneInformation,
                                    sizeof(TIME_ZONE_INFORMATION));
    if (!NT_SUCCESS(Status))
    {
        DPRINT1("NtSetSystemInformation() failed (Status %lx)\n", Status);
        BaseSetLastNTError(Status);
        return FALSE;
    }

    return TRUE;
}
コード例 #2
0
ファイル: actctx.c プロジェクト: Strongc/reactos
/*
 * @implemented
 */
BOOL
WINAPI
GetCurrentActCtx(OUT PHANDLE phActCtx)
{
    NTSTATUS Status;

    /* Check if the output handle pointer was invalid */
    if (phActCtx == NULL)
    {
        /* Set error and bail out */
        BaseSetLastNTError(STATUS_INVALID_PARAMETER);
        return FALSE;
    }

    /* Call the native API */
    Status = RtlGetActiveActivationContext(phActCtx);
    if (!NT_SUCCESS(Status))
    {
        /* Set error and bail out */
        BaseSetLastNTError(STATUS_INVALID_PARAMETER);
        return FALSE;
    }

    /* It worked */
    return TRUE;
}
コード例 #3
0
ファイル: debugger.c プロジェクト: HBelusca/NasuTek-Odyssey
/*
 * @implemented
 */
BOOL
WINAPI
DebugSetProcessKillOnExit(IN BOOL KillOnExit)
{
    HANDLE Handle;
    NTSTATUS Status;
    ULONG State;

    /* Get the debug object */
    Handle = DbgUiGetThreadDebugObject();
    if (!Handle)
    {
        /* Fail */
        BaseSetLastNTError(STATUS_INVALID_HANDLE);
        return FALSE;
    }

    /* Now set the kill-on-exit state */
    State = KillOnExit != 0;
    Status = NtSetInformationDebugObject(Handle,
                                         DebugObjectKillProcessOnExitInformation,
                                         &State,
                                         sizeof(State),
                                         NULL);
    if (!NT_SUCCESS(Status))
    {
        /* Fail */
        BaseSetLastNTError(Status);
        return FALSE;
    }

    /* Success */
    return TRUE;
}
コード例 #4
0
ファイル: actctx.c プロジェクト: Strongc/reactos
/*
 * @implemented
 */
BOOL
WINAPI
ActivateActCtx(IN HANDLE hActCtx,
               OUT PULONG_PTR ulCookie)
{
    NTSTATUS Status;

    /* Check if the handle was invalid */
    if (hActCtx == INVALID_HANDLE_VALUE)
    {
        /* Set error and bail out */
        BaseSetLastNTError(STATUS_INVALID_PARAMETER);
        return FALSE;
    }

    /* Call the native API */
    Status = RtlActivateActivationContext(0, hActCtx, ulCookie);
    if (!NT_SUCCESS(Status))
    {
        /* Set error and bail out */
        BaseSetLastNTError(STATUS_INVALID_PARAMETER);
        return FALSE;
    }

    /* It worked */
    return TRUE;
}
コード例 #5
0
ファイル: vista.c プロジェクト: hoangduit/reactos
/*
 * @implemented
 */
BOOL
WINAPI
QueryFullProcessImageNameW(HANDLE hProcess,
                           DWORD dwFlags,
                           LPWSTR lpExeName,
                           PDWORD pdwSize)
{
    BYTE Buffer[sizeof(UNICODE_STRING) + MAX_PATH * sizeof(WCHAR)];
    UNICODE_STRING *DynamicBuffer = NULL;
    UNICODE_STRING *Result = NULL;
    NTSTATUS Status;
    DWORD Needed;

    Status = NtQueryInformationProcess(hProcess,
                                       ProcessImageFileName,
                                       Buffer,
                                       sizeof(Buffer) - sizeof(WCHAR),
                                       &Needed);
    if (Status == STATUS_INFO_LENGTH_MISMATCH)
    {
        DynamicBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, Needed + sizeof(WCHAR));
        if (!DynamicBuffer)
        {
            BaseSetLastNTError(STATUS_NO_MEMORY);
            return FALSE;
        }

        Status = NtQueryInformationProcess(hProcess,
                                           ProcessImageFileName,
                                           (LPBYTE)DynamicBuffer,
                                           Needed,
                                           &Needed);
        Result = DynamicBuffer;
    }
    else Result = (PUNICODE_STRING)Buffer;

    if (!NT_SUCCESS(Status)) goto Cleanup;

    if (Result->Length / sizeof(WCHAR) + 1 > *pdwSize)
    {
        Status = STATUS_BUFFER_TOO_SMALL;
        goto Cleanup;
    }

    *pdwSize = Result->Length / sizeof(WCHAR);
    memcpy(lpExeName, Result->Buffer, Result->Length);
    lpExeName[*pdwSize] = 0;

Cleanup:
    RtlFreeHeap(RtlGetProcessHeap(), 0, DynamicBuffer);

    if (!NT_SUCCESS(Status))
    {
        BaseSetLastNTError(Status);
    }

    return !Status;
}
コード例 #6
0
ファイル: filemisc.c プロジェクト: mingpen/OpenNT
BOOL
APIENTRY
MoveFileExA(
    LPCSTR lpExistingFileName,
    LPCSTR lpNewFileName,
    DWORD dwFlags
    )

/*++

Routine Description:

    ANSI thunk to MoveFileW

--*/

{

    PUNICODE_STRING Unicode;
    UNICODE_STRING UnicodeNewFileName;
    ANSI_STRING AnsiString;
    NTSTATUS Status;
    BOOL ReturnValue;

    Unicode = &NtCurrentTeb()->StaticUnicodeString;
    RtlInitAnsiString(&AnsiString,lpExistingFileName);
    Status = Basep8BitStringToUnicodeString(Unicode,&AnsiString,FALSE);
    if ( !NT_SUCCESS(Status) ) {
        if ( Status == STATUS_BUFFER_OVERFLOW ) {
            SetLastError(ERROR_FILENAME_EXCED_RANGE);
            }
        else {
            BaseSetLastNTError(Status);
            }
        return FALSE;
        }

    if (ARGUMENT_PRESENT( lpNewFileName )) {
        RtlInitAnsiString(&AnsiString,lpNewFileName);
        Status = Basep8BitStringToUnicodeString(&UnicodeNewFileName,&AnsiString,TRUE);
        if ( !NT_SUCCESS(Status) ) {
            BaseSetLastNTError(Status);
            return FALSE;
            }
        }
    else {
        UnicodeNewFileName.Buffer = NULL;
        }

    ReturnValue = MoveFileExW((LPCWSTR)Unicode->Buffer,(LPCWSTR)UnicodeNewFileName.Buffer,dwFlags);

    if (UnicodeNewFileName.Buffer != NULL) {
        RtlFreeUnicodeString(&UnicodeNewFileName);
        }

    return ReturnValue;
}
コード例 #7
0
ファイル: timezone.c プロジェクト: Moteesh/reactos
/*
 * @implemented
 */
BOOL
WINAPI
SetTimeZoneInformation(CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation)
{
    RTL_TIME_ZONE_INFORMATION TimeZoneInformation;
    NTSTATUS Status;

    DPRINT("SetTimeZoneInformation()\n");

    TimeZoneInformation.Bias = lpTimeZoneInformation->Bias;

    wcsncpy(TimeZoneInformation.StandardName,
            lpTimeZoneInformation->StandardName,
            ARRAYSIZE(TimeZoneInformation.StandardName));
    TimeZoneInformation.StandardDate.Year = lpTimeZoneInformation->StandardDate.wYear;
    TimeZoneInformation.StandardDate.Month = lpTimeZoneInformation->StandardDate.wMonth;
    TimeZoneInformation.StandardDate.Day = lpTimeZoneInformation->StandardDate.wDay;
    TimeZoneInformation.StandardDate.Hour = lpTimeZoneInformation->StandardDate.wHour;
    TimeZoneInformation.StandardDate.Minute = lpTimeZoneInformation->StandardDate.wMinute;
    TimeZoneInformation.StandardDate.Second = lpTimeZoneInformation->StandardDate.wSecond;
    TimeZoneInformation.StandardDate.Milliseconds = lpTimeZoneInformation->StandardDate.wMilliseconds;
    TimeZoneInformation.StandardDate.Weekday = lpTimeZoneInformation->StandardDate.wDayOfWeek;
    TimeZoneInformation.StandardBias = lpTimeZoneInformation->StandardBias;

    wcsncpy(TimeZoneInformation.DaylightName,
            lpTimeZoneInformation->DaylightName,
            ARRAYSIZE(TimeZoneInformation.DaylightName));
    TimeZoneInformation.DaylightDate.Year = lpTimeZoneInformation->DaylightDate.wYear;
    TimeZoneInformation.DaylightDate.Month = lpTimeZoneInformation->DaylightDate.wMonth;
    TimeZoneInformation.DaylightDate.Day = lpTimeZoneInformation->DaylightDate.wDay;
    TimeZoneInformation.DaylightDate.Hour = lpTimeZoneInformation->DaylightDate.wHour;
    TimeZoneInformation.DaylightDate.Minute = lpTimeZoneInformation->DaylightDate.wMinute;
    TimeZoneInformation.DaylightDate.Second = lpTimeZoneInformation->DaylightDate.wSecond;
    TimeZoneInformation.DaylightDate.Milliseconds = lpTimeZoneInformation->DaylightDate.wMilliseconds;
    TimeZoneInformation.DaylightDate.Weekday = lpTimeZoneInformation->DaylightDate.wDayOfWeek;
    TimeZoneInformation.DaylightBias = lpTimeZoneInformation->DaylightBias;

    Status = RtlSetTimeZoneInformation(&TimeZoneInformation);
    if (!NT_SUCCESS(Status))
    {
        DPRINT1("RtlSetTimeZoneInformation() failed (Status %lx)\n", Status);
        BaseSetLastNTError(Status);
        return FALSE;
    }

    Status = NtSetSystemInformation(SystemCurrentTimeZoneInformation,
                                    (PVOID)&TimeZoneInformation,
                                    sizeof(RTL_TIME_ZONE_INFORMATION));
    if (!NT_SUCCESS(Status))
    {
        DPRINT1("NtSetSystemInformation() failed (Status %lx)\n", Status);
        BaseSetLastNTError(Status);
        return FALSE;
    }

    return TRUE;
}
コード例 #8
0
ファイル: iocompl.c プロジェクト: RPG-7/reactos
/*
 * @implemented
 */
BOOL
WINAPI
GetQueuedCompletionStatus(IN HANDLE CompletionHandle,
                          IN LPDWORD lpNumberOfBytesTransferred,
                          OUT PULONG_PTR lpCompletionKey,
                          OUT LPOVERLAPPED *lpOverlapped,
                          IN DWORD dwMilliseconds)
{
    NTSTATUS Status;
    IO_STATUS_BLOCK IoStatus;
    ULONG_PTR CompletionKey;
    LARGE_INTEGER Time;
    PLARGE_INTEGER TimePtr;

    /* Convert the timeout and then call the native API */
    TimePtr = BaseFormatTimeOut(&Time, dwMilliseconds);
    Status = NtRemoveIoCompletion(CompletionHandle,
                                  (PVOID*)&CompletionKey,
                                  (PVOID*)lpOverlapped,
                                  &IoStatus,
                                  TimePtr);
    if (!(NT_SUCCESS(Status)) || (Status == STATUS_TIMEOUT))
    {
        /* Clear out the overlapped output */
        *lpOverlapped = NULL;

        /* Check what kind of error we got */
        if (Status == STATUS_TIMEOUT)
        {
            /* Timeout error is set directly since there's no conversion */
            SetLastError(WAIT_TIMEOUT);
        }
        else
        {
            /* Any other error gets converted */
            BaseSetLastNTError(Status);
        }

        /* This is a failure case */
        return FALSE;
    }

    /* Write back the output parameters */
    *lpCompletionKey = CompletionKey;
    *lpNumberOfBytesTransferred = IoStatus.Information;

    /* Check for error */
    if (!NT_SUCCESS(IoStatus.Status))
    {
        /* Convert and fail */
        BaseSetLastNTError(IoStatus.Status);
        return FALSE;
    }

    /* Return success */
    return TRUE;
}
コード例 #9
0
ファイル: lock.c プロジェクト: GYGit/reactos
/*
 * @implemented
 */
BOOL
WINAPI
LockFileEx(IN HANDLE hFile,
           IN DWORD dwFlags,
           IN DWORD dwReserved,
           IN DWORD nNumberOfBytesToLockLow,
           IN DWORD nNumberOfBytesToLockHigh,
           IN LPOVERLAPPED lpOverlapped)
{
    LARGE_INTEGER BytesToLock, Offset;
    NTSTATUS Status;

    /* Is this a console handle? */
    if (IsConsoleHandle(hFile))
    {
        /* Can't "lock" a console! */
        BaseSetLastNTError(STATUS_INVALID_HANDLE);
        return FALSE;
    }

    /* This parameter should be zero */
    if (dwReserved)
    {
        /* Fail since it isn't */
        SetLastError(ERROR_INVALID_PARAMETER);
        return FALSE;
    }

    /* Set the initial status in the IO_STATUS_BLOCK to pending... */
    lpOverlapped->Internal = STATUS_PENDING;

    /* Convert the parameters to NT format and call the native API */
    Offset.u.LowPart = lpOverlapped->Offset;
    Offset.u.HighPart = lpOverlapped->OffsetHigh;
    BytesToLock.u.LowPart = nNumberOfBytesToLockLow;
    BytesToLock.u.HighPart = nNumberOfBytesToLockHigh;
    Status = NtLockFile(hFile,
                        lpOverlapped->hEvent,
                        NULL,
                        NULL,
                        (PIO_STATUS_BLOCK)lpOverlapped,
                        &Offset,
                        &BytesToLock,
                        0,
                        dwFlags & LOCKFILE_FAIL_IMMEDIATELY ? TRUE : FALSE,
                        dwFlags & LOCKFILE_EXCLUSIVE_LOCK ? TRUE: FALSE);
    if ((NT_SUCCESS(Status)) && (Status != STATUS_PENDING))
    {
        /* Pending status is *not* allowed in the Ex API */
        return TRUE;
    }

    /* Convert the error code and fail */
    BaseSetLastNTError(Status);
    return FALSE;
}
コード例 #10
0
ファイル: toolhelp.c プロジェクト: HBelusca/NasuTek-Odyssey
/*
 * @implemented
 */
HANDLE
WINAPI
CreateToolhelp32Snapshot(DWORD dwFlags, DWORD th32ProcessID)
{
  PRTL_DEBUG_INFORMATION HeapDebug, ModuleDebug;
  PVOID ProcThrdInfo;
  SIZE_T ProcThrdInfoSize;
  NTSTATUS Status;
  HANDLE hSnapShotSection = NULL;

  if(th32ProcessID == 0)
  {
    th32ProcessID = GetCurrentProcessId();
  }

  /*
   * Get all information required for the snapshot
   */
  Status = TH32CreateSnapshot(dwFlags,
                              th32ProcessID,
                              &HeapDebug,
                              &ModuleDebug,
                              &ProcThrdInfo,
                              &ProcThrdInfoSize);
  if(!NT_SUCCESS(Status))
  {
    BaseSetLastNTError(Status);
    return NULL;
  }

  /*
   * Create a section handle and initialize the collected information
   */
  Status = TH32CreateSnapshotSectionInitialize(dwFlags,
                                               th32ProcessID,
                                               HeapDebug,
                                               ModuleDebug,
                                               ProcThrdInfo,
                                               &hSnapShotSection);

  /*
   * Free the temporarily allocated memory which is no longer needed
   */
  TH32FreeAllocatedResources(HeapDebug,
                             ModuleDebug,
                             ProcThrdInfo,
                             ProcThrdInfoSize);

  if(!NT_SUCCESS(Status))
  {
    BaseSetLastNTError(Status);
    return NULL;
  }

  return hSnapShotSection;
}
コード例 #11
0
ファイル: lock.c プロジェクト: GYGit/reactos
/*
 * @implemented
 */
BOOL
WINAPI
LockFile(IN HANDLE hFile,
         IN DWORD dwFileOffsetLow,
         IN DWORD dwFileOffsetHigh,
         IN DWORD nNumberOfBytesToLockLow,
         IN DWORD nNumberOfBytesToLockHigh)
{
    IO_STATUS_BLOCK IoStatusBlock;
    NTSTATUS Status;
    LARGE_INTEGER BytesToLock, Offset;

    /* Is this a console handle? */
    if (IsConsoleHandle(hFile))
    {
        /* Can't "lock" a console! */
        BaseSetLastNTError(STATUS_INVALID_HANDLE);
        return FALSE;
    }

    /* Setup the parameters in NT style and call the native API */
    BytesToLock.u.LowPart = nNumberOfBytesToLockLow;
    BytesToLock.u.HighPart = nNumberOfBytesToLockHigh;
    Offset.u.LowPart = dwFileOffsetLow;
    Offset.u.HighPart = dwFileOffsetHigh;
    Status = NtLockFile(hFile,
                        NULL,
                        NULL,
                        NULL,
                        &IoStatusBlock,
                        &Offset,
                        &BytesToLock,
                        0,
                        TRUE,
                        TRUE);
    if (Status == STATUS_PENDING)
    {
        /* Wait for completion if needed */
        Status = NtWaitForSingleObject(hFile, FALSE, NULL);
        if (NT_SUCCESS(Status)) Status = IoStatusBlock.Status;
    }

    /* Check if we failed */
    if (!NT_SUCCESS(Status))
    {
        /* Convert the error code and fail */
        BaseSetLastNTError(Status);
        return FALSE;
    }

    /* Success! */
    return TRUE;
}
コード例 #12
0
ファイル: loader.c プロジェクト: RareHare/reactos
/*
 * @implemented
 */
FARPROC
WINAPI
GetProcAddress(HMODULE hModule, LPCSTR lpProcName)
{
    ANSI_STRING ProcedureName, *ProcNamePtr = NULL;
    FARPROC fnExp = NULL;
    NTSTATUS Status;
    PVOID hMapped;
    ULONG Ordinal = 0;

    if (HIWORD(lpProcName) != 0)
    {
        /* Look up by name */
        RtlInitAnsiString(&ProcedureName, (LPSTR)lpProcName);
        ProcNamePtr = &ProcedureName;
    }
    else
    {
        /* Look up by ordinal */
        Ordinal = (ULONG)lpProcName;
    }

    /* Map provided handle */
    hMapped = BasepMapModuleHandle(hModule, FALSE);

    /* Get the proc address */
    Status = LdrGetProcedureAddress(hMapped,
                                    ProcNamePtr,
                                    Ordinal,
                                    (PVOID*)&fnExp);

    if (!NT_SUCCESS(Status))
    {
        BaseSetLastNTError(Status);
        return NULL;
    }

    /* Check for a special case when returned pointer is
       the same as iamge's base address */
    if (fnExp == hMapped)
    {
        /* Set correct error code */
        if (HIWORD(lpProcName) != 0)
            BaseSetLastNTError(STATUS_ENTRYPOINT_NOT_FOUND);
        else
            BaseSetLastNTError(STATUS_ORDINAL_NOT_FOUND);

        return NULL;
    }

    /* All good, return procedure pointer */
    return fnExp;
}
コード例 #13
0
ファイル: handle.c プロジェクト: HBelusca/NasuTek-Odyssey
/*
 * @implemented
 */
BOOL
WINAPI
DuplicateHandle(IN HANDLE hSourceProcessHandle,
                IN HANDLE hSourceHandle,
                IN HANDLE hTargetProcessHandle,
                OUT LPHANDLE lpTargetHandle,
                IN DWORD dwDesiredAccess,
                IN BOOL bInheritHandle,
                IN DWORD dwOptions)
{
    NTSTATUS Status;
    HANDLE hTargetHandle;

    hSourceHandle = TranslateStdHandle(hSourceHandle);

    if ((IsConsoleHandle(hSourceHandle)) &&
        ((hSourceHandle != NtCurrentProcess()) &&
         (hSourceHandle != NtCurrentThread())))
    {
        if ((hSourceProcessHandle != NtCurrentProcess()) &&
            (hTargetProcessHandle != NtCurrentProcess()))
        {
            BaseSetLastNTError(STATUS_INVALID_PARAMETER);
            return FALSE;
        }

        hTargetHandle = DuplicateConsoleHandle(hSourceHandle,
                                               dwDesiredAccess,
                                               bInheritHandle,
                                               dwOptions);
        if (hTargetHandle != INVALID_HANDLE_VALUE)
        {
            if (lpTargetHandle) *lpTargetHandle = hTargetHandle;
            return TRUE;
        }

        return FALSE;
    }

    Status = NtDuplicateObject(hSourceProcessHandle,
                               hSourceHandle,
                               hTargetProcessHandle,
                               lpTargetHandle,
                               dwDesiredAccess,
                               bInheritHandle ? OBJ_INHERIT : 0,
                               dwOptions);
    if (NT_SUCCESS(Status)) return TRUE;

    BaseSetLastNTError(Status);
    return FALSE;
}
コード例 #14
0
ファイル: handle.c プロジェクト: HBelusca/NasuTek-Odyssey
/*
 * @implemented
 */
BOOL
WINAPI
SetHandleInformation(IN HANDLE hObject,
                     IN DWORD dwMask,
                     IN DWORD dwFlags)
{
    OBJECT_HANDLE_ATTRIBUTE_INFORMATION HandleInfo;
    ULONG BytesWritten;
    NTSTATUS Status;

    hObject = TranslateStdHandle(hObject);

    if (IsConsoleHandle(hObject))
    {
        /* FIXME: SetConsoleHandleInformation required */
        UNIMPLEMENTED;
        BaseSetLastNTError(STATUS_NOT_IMPLEMENTED);
        return FALSE;
    }

    Status = NtQueryObject(hObject,
                           ObjectHandleFlagInformation,
                           &HandleInfo,
                           sizeof(OBJECT_HANDLE_ATTRIBUTE_INFORMATION),
                           &BytesWritten);
    if (!NT_SUCCESS(Status))
    {
        BaseSetLastNTError(Status);
        return FALSE;
    }

    if (dwMask & HANDLE_FLAG_INHERIT)
    {
        HandleInfo.Inherit = (dwFlags & HANDLE_FLAG_INHERIT) != 0;
    }

    if (dwMask & HANDLE_FLAG_PROTECT_FROM_CLOSE)
    {
        HandleInfo.ProtectFromClose = (dwFlags & HANDLE_FLAG_PROTECT_FROM_CLOSE) != 0;
    }

    Status = NtSetInformationObject(hObject,
                                    ObjectHandleFlagInformation,
                                    &HandleInfo,
                                    sizeof(HandleInfo));
    if (NT_SUCCESS(Status)) return TRUE;

    BaseSetLastNTError(Status);
    return FALSE;
}
コード例 #15
0
ファイル: filemisc.c プロジェクト: mingpen/OpenNT
DWORD
WINAPI
GetCompressedFileSizeA(
    LPCSTR lpFileName,
    LPDWORD lpFileSizeHigh
    )
{

    PUNICODE_STRING Unicode;
    ANSI_STRING AnsiString;
    NTSTATUS Status;

    Unicode = &NtCurrentTeb()->StaticUnicodeString;
    RtlInitAnsiString(&AnsiString,lpFileName);
    Status = Basep8BitStringToUnicodeString(Unicode,&AnsiString,FALSE);
    if ( !NT_SUCCESS(Status) ) {
        if ( Status == STATUS_BUFFER_OVERFLOW ) {
            SetLastError(ERROR_FILENAME_EXCED_RANGE);
            }
        else {
            BaseSetLastNTError(Status);
            }
        return (DWORD)-1;
        }
    return ( GetCompressedFileSizeW((LPCWSTR)Unicode->Buffer,lpFileSizeHigh) );
    return INVALID_FILE_SIZE;
}
コード例 #16
0
ファイル: vista.c プロジェクト: hoangduit/reactos
/*
 * @implemented
 */
BOOL
WINAPI
SleepConditionVariableSRW(IN OUT PCONDITION_VARIABLE ConditionVariable,
                          IN OUT PSRWLOCK SRWLock,
                          IN DWORD dwMilliseconds,
                          IN ULONG Flags)
{
    NTSTATUS Status = 0;
    LARGE_INTEGER TimeOut;
    PLARGE_INTEGER TimeOutPtr = NULL;

    if (dwMilliseconds != INFINITE)
    {
        TimeOut.QuadPart = dwMilliseconds * -10000LL;
        TimeOutPtr = &TimeOut;
    }

#if 0
    Status = RtlSleepConditionVariableSRW((PRTL_CONDITION_VARIABLE)ConditionVariable,
                                          (PRTL_SRWLOCK)SRWLock,
                                          TimeOutPtr,
                                          Flags);
#endif
    if (!NT_SUCCESS(Status))
    {
        BaseSetLastNTError(Status);
        return FALSE;
    }

    return TRUE;
}
コード例 #17
0
ファイル: vista.c プロジェクト: hoangduit/reactos
/*
 * @implemented
 */
BOOL
WINAPI
SleepConditionVariableCS(IN OUT PCONDITION_VARIABLE ConditionVariable,
                         IN OUT PCRITICAL_SECTION CriticalSection,
                         IN DWORD dwMilliseconds)
{
    NTSTATUS Status = 0;
    LARGE_INTEGER TimeOut;
    PLARGE_INTEGER TimeOutPtr = NULL;

    if (dwMilliseconds != INFINITE)
    {
        TimeOut.QuadPart = dwMilliseconds * -10000LL;
        TimeOutPtr = &TimeOut;
    }

#if 0
    Status = RtlSleepConditionVariableCS((PRTL_CONDITION_VARIABLE)ConditionVariable,
                                         (PRTL_CRITICAL_SECTION)CriticalSection,
                                         TimeOutPtr);
#endif
    if (!NT_SUCCESS(Status))
    {
        BaseSetLastNTError(Status);
        return FALSE;
    }

    return TRUE;
}
コード例 #18
0
ファイル: alias.c プロジェクト: RareHare/reactos
/*
 * @implemented
 */
DWORD
WINAPI
GetConsoleAliasExesLengthW(VOID)
{
    NTSTATUS Status;
    CONSOLE_API_MESSAGE ApiMessage;
    PCONSOLE_GETALIASESEXESLENGTH GetAliasesExesLengthRequest = &ApiMessage.Data.GetAliasesExesLengthRequest;

    DPRINT("GetConsoleAliasExesLengthW entered\n");

    GetAliasesExesLengthRequest->Length = 0;

    Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
                                 NULL,
                                 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAliasExesLength),
                                 sizeof(CONSOLE_GETALIASESEXESLENGTH));

    if (!NT_SUCCESS(Status))
    {
        BaseSetLastNTError(Status);
        return 0;
    }

    return GetAliasesExesLengthRequest->Length;
}
コード例 #19
0
ファイル: rw.c プロジェクト: hoangduit/reactos
/*
 * @implemented
 */
BOOL WINAPI
ReadFileEx(IN HANDLE hFile,
           IN LPVOID lpBuffer,
           IN DWORD nNumberOfBytesToRead OPTIONAL,
           IN LPOVERLAPPED lpOverlapped,
           IN LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
{
    LARGE_INTEGER Offset;
    NTSTATUS Status;

    Offset.u.LowPart = lpOverlapped->Offset;
    Offset.u.HighPart = lpOverlapped->OffsetHigh;
    lpOverlapped->Internal = STATUS_PENDING;

    Status = NtReadFile(hFile,
                        NULL,
                        ApcRoutine,
                        lpCompletionRoutine,
                        (PIO_STATUS_BLOCK)lpOverlapped,
                        lpBuffer,
                        nNumberOfBytesToRead,
                        &Offset,
                        NULL);

    if (!NT_SUCCESS(Status))
    {
        BaseSetLastNTError(Status);
        return FALSE;
    }

    return TRUE;
}
コード例 #20
0
ファイル: sysinfo.c プロジェクト: HBelusca/NasuTek-Odyssey
/*
 * @implemented
 */
BOOL
WINAPI
GetLogicalProcessorInformation(OUT PSYSTEM_LOGICAL_PROCESSOR_INFORMATION Buffer,
                               IN OUT PDWORD ReturnLength)
{
    NTSTATUS Status;

    if (!ReturnLength)
    {
        SetLastError(ERROR_INVALID_PARAMETER);
        return FALSE;
    }

    Status = NtQuerySystemInformation(SystemLogicalProcessorInformation,
                                      Buffer,
                                      *ReturnLength,
                                      ReturnLength);

    /* Normalize the error to what Win32 expects */
    if (Status == STATUS_INFO_LENGTH_MISMATCH) Status = STATUS_BUFFER_TOO_SMALL;
    if (!NT_SUCCESS(Status))
    {
        BaseSetLastNTError(Status);
        return FALSE;
    }

    return TRUE;
}
コード例 #21
0
ファイル: synch.c プロジェクト: HBelusca/NasuTek-Odyssey
/*
 * @implemented
 */
BOOL
WINAPI
SetWaitableTimer(IN HANDLE hTimer,
                 IN const LARGE_INTEGER *pDueTime,
                 IN LONG lPeriod,
                 IN PTIMERAPCROUTINE pfnCompletionRoutine OPTIONAL,
                 IN OPTIONAL LPVOID lpArgToCompletionRoutine,
                 IN BOOL fResume)
{
    NTSTATUS Status;

    /* Set the timer */
    Status = NtSetTimer(hTimer,
                        (PLARGE_INTEGER)pDueTime,
                        (PTIMER_APC_ROUTINE)pfnCompletionRoutine,
                        lpArgToCompletionRoutine,
                        (BOOLEAN)fResume,
                        lPeriod,
                        NULL);
    if (NT_SUCCESS(Status)) return TRUE;

    /* If we got here, then we failed */
    BaseSetLastNTError(Status);
    return FALSE;
}
コード例 #22
0
ファイル: filemap.c プロジェクト: HBelusca/NasuTek-Odyssey
/*
 * @implemented
 */
BOOL
NTAPI
FlushViewOfFile(LPCVOID lpBaseAddress,
                SIZE_T dwNumberOfBytesToFlush)
{
    SIZE_T NumberOfBytesToFlush;
    NTSTATUS Status;
    IO_STATUS_BLOCK IoStatusBlock;

    /* Save amount of bytes to flush to a local var */
    NumberOfBytesToFlush = dwNumberOfBytesToFlush;

    /* Flush the view */
    Status = NtFlushVirtualMemory(NtCurrentProcess(),
                                  (LPVOID)lpBaseAddress,
                                  &NumberOfBytesToFlush,
                                  &IoStatusBlock);
    if (!NT_SUCCESS(Status))
    {
        /* We failed */
        BaseSetLastNTError(Status);
        return FALSE;
    }

    /* Return success */
    return TRUE;
}
コード例 #23
0
ファイル: debugger.c プロジェクト: HBelusca/NasuTek-Odyssey
HANDLE
WINAPI
ProcessIdToHandle(IN DWORD dwProcessId)
{
    NTSTATUS Status;
    OBJECT_ATTRIBUTES ObjectAttributes;
    HANDLE Handle;
    CLIENT_ID ClientId;

    /* If we don't have a PID, look it up */
    if (dwProcessId == MAXDWORD) dwProcessId = (DWORD_PTR)CsrGetProcessId();

    /* Open a handle to the process */
    ClientId.UniqueThread = NULL;
    ClientId.UniqueProcess = UlongToHandle(dwProcessId);
    InitializeObjectAttributes(&ObjectAttributes, NULL, 0, NULL, NULL);
    Status = NtOpenProcess(&Handle,
                           PROCESS_CREATE_THREAD | PROCESS_VM_OPERATION |
                           PROCESS_VM_WRITE | PROCESS_VM_READ |
                           PROCESS_SUSPEND_RESUME | PROCESS_QUERY_INFORMATION,
                           &ObjectAttributes,
                           &ClientId);
    if (!NT_SUCCESS(Status))
    {
        /* Fail */
        BaseSetLastNTError(Status);
        return 0;
    }

    /* Return the handle */
    return Handle;
}
コード例 #24
0
ファイル: debugger.c プロジェクト: HBelusca/NasuTek-Odyssey
/*
 * @implemented
 */
BOOL
WINAPI
CheckRemoteDebuggerPresent(IN HANDLE hProcess,
                           OUT PBOOL pbDebuggerPresent)
{
    HANDLE DebugPort;
    NTSTATUS Status;

    /* Make sure we have an output and process*/
    if (!(pbDebuggerPresent) || !(hProcess))
    {
        /* Fail */
        SetLastError(ERROR_INVALID_PARAMETER);
        return FALSE;
    }

    /* Check if the process has a debug object/port */
    Status = NtQueryInformationProcess(hProcess,
                                       ProcessDebugPort,
                                       (PVOID)&DebugPort,
                                       sizeof(HANDLE),
                                       NULL);
    if (NT_SUCCESS(Status))
    {
        /* Return the current state */
        *pbDebuggerPresent = DebugPort != NULL;
        return TRUE;
    }

    /* Otherwise, fail */
    BaseSetLastNTError(Status);
    return FALSE;
}
コード例 #25
0
ファイル: filemisc.c プロジェクト: mingpen/OpenNT
BOOL
APIENTRY
DeleteFileA(
    LPCSTR lpFileName
    )

/*++

Routine Description:

    ANSI thunk to DeleteFileW

--*/

{
    PUNICODE_STRING Unicode;
    ANSI_STRING AnsiString;
    NTSTATUS Status;

    Unicode = &NtCurrentTeb()->StaticUnicodeString;
    RtlInitAnsiString(&AnsiString,lpFileName);
    Status = Basep8BitStringToUnicodeString(Unicode,&AnsiString,FALSE);
    if ( !NT_SUCCESS(Status) ) {
        if ( Status == STATUS_BUFFER_OVERFLOW ) {
            SetLastError(ERROR_FILENAME_EXCED_RANGE);
            }
        else {
            BaseSetLastNTError(Status);
            }
        return FALSE;
        }
    return ( DeleteFileW((LPCWSTR)Unicode->Buffer) );
}
コード例 #26
0
ファイル: synch.c プロジェクト: HBelusca/NasuTek-Odyssey
/*
 * @implemented
 */
BOOL
WINAPI
UnregisterWaitEx(IN HANDLE WaitHandle,
                 IN HANDLE CompletionEvent)
{
    NTSTATUS Status;

    /* Check for invalid handle */
    if (!WaitHandle)
    {
        /* Fail */
        SetLastError(ERROR_INVALID_HANDLE);
        return FALSE;
    }

    /* Deregister the wait and check status */
    Status = RtlDeregisterWaitEx(WaitHandle, CompletionEvent);
    if (!(NT_SUCCESS(Status)) ||
        ((CompletionEvent != INVALID_HANDLE_VALUE) && (Status == STATUS_PENDING)))
    {
        /* Failure or non-blocking call */
        BaseSetLastNTError(Status);
        return FALSE;
    }

    /* All good */
    return TRUE;
}
コード例 #27
0
ファイル: iocompl.c プロジェクト: RPG-7/reactos
/*
 * @implemented
 */
BOOL
WINAPI
PostQueuedCompletionStatus(IN HANDLE CompletionHandle,
                           IN DWORD dwNumberOfBytesTransferred,
                           IN ULONG_PTR dwCompletionKey,
                           IN LPOVERLAPPED lpOverlapped)
{
    NTSTATUS Status;

    /* Call the native API */
    Status = NtSetIoCompletion(CompletionHandle,
                               (PVOID)dwCompletionKey,
                               (PVOID)lpOverlapped,
                               STATUS_SUCCESS,
                               dwNumberOfBytesTransferred);
    if (!NT_SUCCESS(Status))
    {
        /* Convert the error and fail */
        BaseSetLastNTError(Status);
        return FALSE;
    }

    /* Success path */
    return TRUE;
}
コード例 #28
0
ファイル: debugger.c プロジェクト: HBelusca/NasuTek-Odyssey
/*
 * @implemented
 */
BOOL
WINAPI
ContinueDebugEvent(IN DWORD dwProcessId,
                   IN DWORD dwThreadId,
                   IN DWORD dwContinueStatus)
{
    CLIENT_ID ClientId;
    NTSTATUS Status;

    /* Set the Client ID */
    ClientId.UniqueProcess = (HANDLE)dwProcessId;
    ClientId.UniqueThread = (HANDLE)dwThreadId;

    /* Continue debugging */
    Status = DbgUiContinue(&ClientId, dwContinueStatus);
    if (!NT_SUCCESS(Status))
    {
        /* Fail */
        BaseSetLastNTError(Status);
        return FALSE;
    }

    /* Remove the process/thread handles */
    RemoveHandles(dwProcessId, dwThreadId);

    /* Success */
    return TRUE;
}
コード例 #29
0
ファイル: resntfy.c プロジェクト: Nevermore2015/reactos
/*
 * @implemented
 */
BOOL
WINAPI
QueryMemoryResourceNotification(IN HANDLE ResourceNotificationHandle,
                                OUT PBOOL ResourceState)
{
    EVENT_BASIC_INFORMATION EventInfo;
    NTSTATUS Status;

    if ((ResourceNotificationHandle) &&
        (ResourceNotificationHandle != INVALID_HANDLE_VALUE) &&
        (ResourceState))
    {
        Status = NtQueryEvent(ResourceNotificationHandle,
                              EventBasicInformation,
                              &EventInfo,
                              sizeof(EventInfo),
                              NULL);
        if (NT_SUCCESS(Status))
        {
            *ResourceState = (EventInfo.EventState == 1);
            return TRUE;
        }

        BaseSetLastNTError(Status);
    }
    else
    {
        SetLastError(ERROR_INVALID_PARAMETER);
    }

    return FALSE;
}
コード例 #30
0
ファイル: actctx.c プロジェクト: Strongc/reactos
/*
 * @implemented
 */
BOOL
WINAPI
DeactivateActCtx(IN DWORD dwFlags,
                 IN ULONG_PTR ulCookie)
{
    ULONG NativeFlags;

    /* Check if the flags are invalid */
    if ((dwFlags & ~DEACTIVATE_ACTCTX_FLAG_FORCE_EARLY_DEACTIVATION) != 0)
    {
        /* Set error and bail out */
        BaseSetLastNTError(STATUS_INVALID_PARAMETER);
        return FALSE;
    }

    /* Convert flags */
    NativeFlags = 0;
    if (dwFlags & DEACTIVATE_ACTCTX_FLAG_FORCE_EARLY_DEACTIVATION)
    {
        NativeFlags = RTL_DEACTIVATE_ACTIVATION_CONTEXT_FLAG_FORCE_EARLY_DEACTIVATION;
    }

    /* Call the native API -- it can never fail */
    RtlDeactivateActivationContext(NativeFlags, ulCookie);
    return TRUE;
}