@@ -45,16 +45,16 @@ var advApi = {
4545 _Inout_opt_ LPDWORD lpcbData
4646 );
4747 */
48- RegQueryValueExA : function ( hKey , valueName , shouldBeNull , lpType , lpData , lpcbData ) {
49- debug ( 'RegQueryValueExA ' ) ;
48+ RegQueryValueExW : function ( hKey , valueName , shouldBeNull , lpType , lpData , lpcbData ) {
49+ debug ( 'RegQueryValueExW ' ) ;
5050 if ( lpData === null ) {
5151 debug ( keys [ hKey . address ( ) ] . values . test_value_name ) ;
5252 lpType . writeUInt32LE ( windef . REG_VALUE_TYPE . REG_SZ , 0 ) ;
5353 lpcbData . writeUInt32LE ( keys [ hKey . address ( ) ] . values [ valueName ] . length , 0 ) ;
5454 return 0 ;
5555 }
5656
57- lpData . write ( keys [ hKey . address ( ) ] . values [ valueName ] . value , 'utf8' ) ;
57+ keys [ hKey . address ( ) ] . values [ valueName ] . valueBuffer . copy ( lpData ) ;
5858 lpType . writeUInt16LE ( windef . REG_VALUE_TYPE . REG_SZ ) ;
5959 return 0 ;
6060 } ,
@@ -67,9 +67,9 @@ var advApi = {
6767 _Out_ PHKEY phkResult
6868 );
6969 */
70- RegOpenKeyExA : function ( hKey , subKeyName , shouldBeZero , accessLevel , pHkey ) {
70+ RegOpenKeyExW : function ( hKey , subKeyName , shouldBeZero , accessLevel , pHkey ) {
7171 var accessLevelFound = findValueInHash ( accessLevel , windef . KEY_ACCESS ) ;
72- debug ( 'Mock: RegOpenKeyExA subkey: ' + subKeyName ) ;
72+ debug ( 'Mock: RegOpenKeyExW subkey: ' + subKeyName ) ;
7373 if ( hKey . address ) {
7474 debug ( 'Mock: hKey address:' + hKey . address ( ) ) ;
7575 }
@@ -123,8 +123,8 @@ var advApi = {
123123 _In_ DWORD cbData
124124 );
125125 */
126- RegSetValueExA : function ( hKey , valueName , shouldBeNull , valueType , valueBuffer , bufferLength ) {
127- debug ( 'Mock: RegSetValueExA ' ) ;
126+ RegSetValueExW : function ( hKey , valueName , shouldBeNull , valueType , valueBuffer , bufferLength ) {
127+ debug ( 'Mock: RegSetValueExW ' ) ;
128128 // predefined key
129129 if ( typeof hKey === 'number' ) {
130130 assert ( findValueInHash ( hKey , windef . HKEY ) , 'Mock: Invalid predefined key specified' ) ;
@@ -136,9 +136,16 @@ var advApi = {
136136 assert ( valueBuffer . constructor === Buffer ) ;
137137 assert ( typeof bufferLength === 'number' ) ;
138138
139+ // Use the passed length, not the length of valueBuffer
140+ var value = ref . reinterpret ( valueBuffer , bufferLength , 0 ) ;
141+
142+ // Copy the value to a new buffer and store that
143+ var valueCopy = new Buffer ( bufferLength ) ;
144+ value . copy ( valueCopy , 0 , 0 , bufferLength ) ;
145+
139146 keys [ hKey . address ( ) ] . values [ valueName ] = {
140147 valueType : valueType ,
141- value : ref . readCString ( valueBuffer ) ,
148+ valueBuffer : valueCopy ,
142149 length : bufferLength
143150 } ;
144151 return 0 ;
@@ -156,8 +163,8 @@ var advApi = {
156163 _Out_opt_ LPDWORD lpdwDisposition
157164 );
158165 */
159- RegCreateKeyExA : function ( hKey , subKeyName , shouldBeNull , shouldBeNull2 , securityAttributes , accessLevel , shouldBeNull3 , pHkey , shouldBeNull4 ) {
160- debug ( 'Mock: RegCreateKeyExA ' ) ;
166+ RegCreateKeyExW : function ( hKey , subKeyName , shouldBeNull , shouldBeNull2 , securityAttributes , accessLevel , shouldBeNull3 , pHkey , shouldBeNull4 ) {
167+ debug ( 'Mock: RegCreateKeyExW ' ) ;
161168 assert ( hKey . constructor === Buffer ) ;
162169 assert ( typeof subKeyName === 'string' ) ;
163170 assert ( shouldBeNull === null ) ;
@@ -192,7 +199,7 @@ var advApi = {
192199 _In_opt_ LPCTSTR lpSubKey
193200 );
194201 */
195- RegDeleteTreeA : function ( hKey , subKeyName ) {
202+ RegDeleteTreeW : function ( hKey , subKeyName ) {
196203 if ( typeof hKey === 'number' ) {
197204 assert ( findValueInHash ( hKey , windef . HKEY ) , 'Mock: Invalid predefined key specified' ) ;
198205 } else {
0 commit comments