Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.5 KiB

  1. /*++
  2. Copyright (c) 1991-92 Microsoft Corporation
  3. Module Name:
  4. ReqSize.c
  5. Abstract:
  6. This contains RxpComputeRequestBufferSize. This returns the size (in
  7. bytes) necessary to hold the request buffer.
  8. Author:
  9. John Rogers (JohnRo) 20-Aug-1991
  10. Revision History:
  11. 11-May-1991 JohnRo
  12. Created.
  13. 20-Aug-1991 JohnRo
  14. Changed to move toward UNICODE possibility. Added this header.
  15. 31-Mar-1992 JohnRo
  16. Prevent too large size requests.
  17. --*/
  18. // These must be included first:
  19. #include <windef.h> // DWORD, IN, OPTIONAL, WORD, etc.
  20. #include <lmcons.h> // NET_API_STATUS
  21. // These may be included in any order:
  22. #include <netdebug.h> // NetpAssert().
  23. #include <rap.h> // DESC_CHAR, LPDESC, etc.
  24. #include <rxp.h> // My prototype, MAX_TRANSACT_ equates.
  25. DWORD
  26. RxpComputeRequestBufferSize(
  27. IN LPDESC ParmDesc,
  28. IN LPDESC DataDescSmb OPTIONAL,
  29. IN DWORD DataSize
  30. )
  31. {
  32. DWORD BytesNeeded;
  33. NetpAssert( ParmDesc != NULL );
  34. NetpAssert( RapIsValidDescriptorSmb( ParmDesc ) );
  35. if (DataDescSmb != NULL) {
  36. NetpAssert( RapIsValidDescriptorSmb( DataDescSmb ) );
  37. }
  38. BytesNeeded = sizeof(WORD) // api number
  39. + DESCLEN( ParmDesc ) + 1;
  40. if (DataDescSmb != NULL) {
  41. BytesNeeded += DESCLEN( DataDescSmb ) + 1;
  42. } else {
  43. BytesNeeded += 1; // just null char
  44. }
  45. BytesNeeded += DataSize;
  46. NetpAssert( BytesNeeded <= MAX_TRANSACT_SEND_PARM_SIZE );
  47. return (BytesNeeded);
  48. }