⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 random.c

📁 Vitual Ring Routing 管你知不知道
💻 C
字号:
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil -*- (for GNU Emacs)
//
// (c) Microsoft Corporation. All rights reserved. 
//
// This file is part of the Microsoft Virtual Ring Routing distribution.
// You should have received a copy of the Microsoft Research Shared Source
// license agreement (MSR-SSLA) for this software; see the file "license.txt".
// If not, please see http://research.microsoft.com/vrr/license.htm,
// or write to Microsoft Research, One Microsoft Way, Redmond, WA 98052-6399.
//
// This file is derived from the Microsoft Research Mesh Connectivity Layer,
// available under the MSR-SSLA license, and downloadable from
// http://research.microsoft.com/mesh/.
//

#include "headers.h"
//* RandomInit
//
//  Initialize the pseudo-random number module.
//  Returns TRUE for success and FALSE for failure.
// 
int
RandomInit(void)
{
    SeedRandom(1);
    return TRUE;
}

//* GetRandom
//
//  Get random bytes.
//
void
GetRandom(uchar *Buffer, uint Length)
{
    while (Length > 0) {
        register uint NumBytes = min(Length, 4);
        uint Block = GetRandomNumber(0xffffffff);
        RtlCopyMemory(Buffer,&Block,NumBytes);
        Buffer += NumBytes;
        Length -= NumBytes;
    }
}

uint
GetRandomNumber(uint Max)
{
    return RandomNumber(0,Max);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -