Source code of Windows XP (NT5)
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.

175 lines
4.4 KiB

  1. TITLE "String support routines"
  2. ;++
  3. ;
  4. ; Copyright (c) 1989 Microsoft Corporation
  5. ;
  6. ; Module Name:
  7. ;
  8. ; stringsup.asm
  9. ;
  10. ; Abstract:
  11. ;
  12. ; This module implements suplimentary routines for performing string
  13. ; operations.
  14. ;
  15. ; Author:
  16. ;
  17. ; Larry Osterman (larryo) 18-Sep-1991
  18. ;
  19. ; Environment:
  20. ;
  21. ; Any mode.
  22. ;
  23. ; Revision History:
  24. ;
  25. ;--
  26. .386p
  27. include callconv.inc ; calling convention macros
  28. _TEXT SEGMENT DWORD PUBLIC 'CODE'
  29. ASSUME DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING
  30. page ,132
  31. subttl "RtlInitAnsiString"
  32. ;++
  33. ;
  34. ; VOID
  35. ; RtlInitAnsiString(
  36. ; OUT PANSI_STRING DestinationString,
  37. ; IN PSZ SourceString OPTIONAL
  38. ; )
  39. ;
  40. ;
  41. ; Routine Description:
  42. ;
  43. ; The RtlInitAnsiString function initializes an NT counted string.
  44. ; The DestinationString is initialized to point to the SourceString
  45. ; and the Length and MaximumLength fields of DestinationString are
  46. ; initialized to the length of the SourceString, which is zero if
  47. ; SourceString is not specified.
  48. ;
  49. ; Arguments:
  50. ;
  51. ; (TOS+4) = DestinationString - Pointer to the counted string to initialize
  52. ;
  53. ; (TOS+8) = SourceString - Optional pointer to a null terminated string that
  54. ; the counted string is to point to.
  55. ;
  56. ;
  57. ; Return Value:
  58. ;
  59. ; None.
  60. ;
  61. ; NOTE:
  62. ; This routine assumes that the string is less than 64K in size.
  63. ;
  64. ;--
  65. cPublicProc _RtlInitString ,2
  66. cPublicFpo 2,2
  67. push edi
  68. mov edi,[esp]+8+4 ; (edi)= SourceString
  69. mov edx,[esp]+4+4 ; (esi)= DestinationString
  70. mov DWORD PTR [edx], 0 ; (Destination).Length = (Destination).MaximumLength = 0
  71. mov DWORD PTR [edx]+4, edi ; (Destination).Buffer = 0
  72. or edi, edi
  73. jz @f
  74. or ecx, -1
  75. xor eax, eax
  76. repne scasb
  77. not ecx
  78. mov [edx]+2, cx ; Save maximum length
  79. dec ecx
  80. mov [edx], cx ; Save length
  81. @@: pop edi
  82. stdRET _RtlInitString
  83. stdENDP _RtlInitString
  84. cPublicProc _RtlInitAnsiString ,2
  85. cPublicFpo 2,2
  86. push edi
  87. mov edi,[esp]+8+4 ; (edi)= SourceString
  88. mov edx,[esp]+4+4 ; (esi)= DestinationString
  89. mov DWORD PTR [edx], 0 ; (Destination).Length = (Destination).MaximumLength = 0
  90. mov DWORD PTR [edx]+4, edi ; (Destination).Buffer = 0
  91. or edi, edi
  92. jz @f
  93. or ecx, -1
  94. xor eax, eax
  95. repne scasb
  96. not ecx
  97. mov [edx]+2, cx ; Save maximum length
  98. dec ecx
  99. mov [edx], cx ; Save length
  100. @@: pop edi
  101. stdRET _RtlInitAnsiString
  102. stdENDP _RtlInitAnsiString
  103. page
  104. subttl "RtlInitUnicodeString"
  105. ;++
  106. ;
  107. ; VOID
  108. ; RtlInitUnicodeString(
  109. ; OUT PUNICODE_STRING DestinationString,
  110. ; IN PWSTR SourceString OPTIONAL
  111. ; )
  112. ;
  113. ;
  114. ; Routine Description:
  115. ;
  116. ; The RtlInitUnicodeString function initializes an NT counted string.
  117. ; The DestinationString is initialized to point to the SourceString
  118. ; and the Length and MaximumLength fields of DestinationString are
  119. ; initialized to the length of the SourceString, which is zero if
  120. ; SourceString is not specified.
  121. ;
  122. ; Arguments:
  123. ;
  124. ; (TOS+4) = DestinationString - Pointer to the counted string to initialize
  125. ;
  126. ; (TOS+8) = SourceString - Optional pointer to a null terminated string that
  127. ; the counted string is to point to.
  128. ;
  129. ;
  130. ; Return Value:
  131. ;
  132. ; None.
  133. ;
  134. ; NOTE:
  135. ; This routine assumes that the string is less than 64K in size.
  136. ;
  137. ;--
  138. cPublicProc _RtlInitUnicodeString ,2
  139. cPublicFpo 2,2
  140. push edi
  141. mov edi,[esp]+8+4 ; (edi)= SourceString
  142. mov edx,[esp]+4+4 ; (esi)= DestinationString
  143. mov DWORD PTR [edx], 0 ; (Destination).Length = (Destination).MaximumLength = 0
  144. mov DWORD PTR [edx]+4, edi ; (Destination).Buffer = 0
  145. or edi, edi
  146. jz @f
  147. or ecx, -1
  148. xor eax, eax
  149. repne scasw
  150. not ecx
  151. shl ecx,1
  152. mov [edx]+2, cx ; Save maximum length
  153. dec ecx
  154. dec ecx
  155. mov [edx], cx ; Save length
  156. @@: pop edi
  157. stdRET _RtlInitUnicodeString
  158. stdENDP _RtlInitUnicodeString
  159. _TEXT ends
  160. end