Avi write and read vi's

I start to test new AVI vi's Imaq 7.0. Is it possible to read an AVI file while I am writing to it. When I am trying to do it I get an I/O file error.
Is it also possible to append new frames to an existing avi. I couldn't achieved it with Imaq 7.0 vi's.
Many thanks

You can't read and write the same file at the same time.
I don't see any options to append images to an avi file. That would be a nice feature for them to add.
Bruce
Bruce Ammons
Ammons Engineering

Similar Messages

  • How to combine both DAQ AI signal, write and read file in single VI

    Hi
     I am the new user of LabVIEW version 7.1 for testing automation application. I have to measure 33 signals ( mostly analog like temp, pressure, etc...) from NI USB 6210 DAQ system and write in master file for future verfication.From real data or from master file back up have to write  one more file if only the signal reaches steady state , which will used for analysis and same signals to be read from this file parallely & make a waveform and/or table display format.
    Pl. help me to shortout this problem 
    note: I have plan to ugrade labVIEW version 2011 shortly, so let me know doing parrel acquistion write and read file for data analysis in same VI in version 7.1...... 

    Parallel operations in LabVIEW are very simple.  Just code it in parallel and it will work.
    Try taking a look at some of the examples in the NI Example Finder (Help > Find Examples).  There you will find example for writing to and reading from files, as well as data acquistion in parallel with other operations.
    You might need a producer/consumer architecture is you are acquiring data very quickly.
    Chris
    Certified LabVIEW Architect
    Certified TestStand Architect

  • Closing a serial port after executing a for loop of write and reads.

    Hello,
    Labview is opening and then closing each write to the port. I have tried to leave the close outside of the for loop, but labview wont allow it. What do I need to change to make all the writes and reads execute on 1 open and close of the serial port.?
    Thanks.
    Attachments:
    Controller.vi ‏27 KB

    J_es--
         The program that you posted looks to be ok for the most part, you might consider putting an open after your configure (but that's trivial). The other thing that is a minor issue is the loop tunnel coming out of your for loop is currently being auto-indexed.  This function is used to index data for each interation of the loop.  You are using a static address (not an array) and so you don't need this.  If you right-click and remove the auto-index the broken wire will go away. Other than that it should be ok.
         I would suggest looking at one of the shipping examples that come with LabVIEW.  "Basic Serial Read and Write" is essentially the same thing that you are doing and is tested here and might save you a bit of time.  Anyway, take a look if you have a second. Best of luck with your application!
    John H.
    Applications Engineer
    National Instruments
    http://www.ni.com/support

  • How can i write and read the same data

    hi,
             i have attached my program to this mail. i have some problems in this program.
    problems:
    1. I want to select the threshold for the rms,varience and s.d.
    But what i used is not doing that. i want to fix the upper threshold value and lower threshold value.
     when ever the input crosses upper threshold value i want the output and it will remains uptill the value above the lower threshold value.
    Once it come down the lower threshold value the output should be stopped.
    2. I want to write this in to a  file and i want to read this file. is this possible or not. 
                please try to help me i am very new with lab view6i
           REGARDS
    CHAMARTHY KOMAL DILEEP.
       [email protected]
    Attachments:
    dileep.vi ‏93 KB

    The easiest way to perform a certain action (such as file I/O) based on a certain condition (such as whether a value has passed a certain threshold) is to use a comparison VI in combination with a case structure. Then you can specify that if your rms, standard deviation and variance are above a threshold then perform a certain action.
    Also consider using shift registers to keep track of data from the last loop. If I understand you correctly, you want to start logging data when an upper threshold has been passed. Then you want to continue logging data until a lower threshold is passed. I have attached a non-functional but explanatory VI that will help explain how to implement logic to that effect. It also demonstrates that you can indeed write and read from the same file in a loop. The best way to do this is to open the file before the loop, do all the necessary writing and reading in the loop, and then close the file after the loop.
    Hope this helps!
    Jarrod S.
    National Instruments
    Attachments:
    dileep_example.vi ‏61 KB

  • NI 6602 Write and Read Frequency

    Hi all ,
    I Have NI 6602 timing card and i'm trying to use it in order to write and read using the
    DAQmxWriteCtrFreq (taskHandle1, 0, 1, 10.0, DAQmx_Val_GroupByChannel, &freq, &duty, &writtenVal, 0);
    and
    DAQmxReadCounterScalarF64(taskHandle2,10.0,&dataVal,0);
    what i'm trying to do is to write to ctt0 and to read from ctr7 ( they are crossed in the card )
    i'm having a bit problems with that can some one give me a tip on how to do it properly ?
    just write freq to ctr0 and read freq from ctr7.....
    Kobi Kalif
    Software Engineer
    Solved!
    Go to Solution.

    You should have the following sample installed on your PC that may help you in this task: DigPulseTrain-Cont.prj (it could be located in \program files\National Instruments\CVIx\samples\daqmx\counter\generate pulse folder)
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • DAQ vi to perform digital write and read measurements using 32 bits binary data saved in a file

    Hi
    DAQ vi to perform digital write and read measurements using 32 bits binary data saved in a file
    Two main
    sections:
    1)     
    Perform
    write and read operations to and fro different spread sheet files, such that
    each file have a single row of 32bits different binary data (analogous to 1D
    array) where the left most bit is the MSB. I don’t want to manually enter the
    32 bits binary data, I want the data written or read just by opening a file
    name saves with the intended data.
          2)     
    And
    by using test patterns implemented using the digital pattern generator or  build digital data functions or otherwise, I need to
    ensure that the     
                binary data written to a spreadsheet file or any supported file type
    then through the NI-USB 6509 is same as the data read.
    I’m aware I can’t use the simulated
    device to read data written to any port but if the write part of the vi works I
    ‘m sure the read part will work on the physical device which I’ll buy later.
    My Plan
    of action
    I’ve
    created a basic write/read file task and a write/read DAQ task for NI USB 6509
    and both combine in a while loop to form a progress VI which I’m confuse of how
    to proceed with the implementation.
    My
    greatest problem is to link both together with the correct functions or operators
    such that there are no syntax/execution errors and thus achieve my intended
    result.
    This
    project is one of my many assignments for my master thesis, so please i’ll
    appreciate every help as I’m not really efficient with LabVIEW programming but
    I prefer it because is fun and interesting if I get to know it.
    Currently I’m
    practicing with LabVIEW 8.6/NI DAQmx 8.8 Demo versions and NI USB 6509
    simulated device.
    Please see
    the attached file for my novice progress, thanks in
    advance for the support
    Rgds
    Paul
    Attachments:
    DIO_write_read DAQ from file.vi ‏17 KB

    What does your file look like?  The DAQmx write is expecting a single U32 value, not an array of I64. 
    Message Edited by vt92 on 09-16-2009 02:42 PM
    "There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal

  • Options for having cFP write and read file

    I have a cFP VI that runs on a cFP 2110 controller for doing process automation on a custom piece of equipment.  It seems that each month we use the same equipment for a slightly different automated process routine.  What I have done in the past is to make a copy of my VI's and real-time project and then make the changes in the code for the new process.  Most of the changes to the code between processes are just changes to numeric controllers to change ramp and slope times or the number of times the code repeats a set of steps.  I have been playing around with writing a sort of configurations page to my VI to allow the user to change some numeric controls, save them to a file using the Read Key.VI and Write Key.VI.  In the simple tests I have done, this works If I have a target VI on the cFP 2110 and a host VI where I can have the configurations page and save the file to my computer's hard drive. 
    The configurations file I would create would probably have 15-30 numeric controls and maybe some string commands.  I have a couple of questions about doing this.  Do I need to go back and create both Target and Host VI and communicate between the two using shared variables, or can I just keep my current VI and write a subVI that would save my files to the cFP controller?  If I save the files to the cFP controller, can user set the numeric controller and save the file and/or  likewise call-up any of say one of say 10 differnet files to populate the various sub-VI and run? 
    Finally, provided that I can write and read these small configuration numeric controller files to the controller, is there any advantage to writing the files to one method or the other: writing to the controller vs, creating a target and host VI to load the data?
    Thank you for the help. 
    Danny
    Attachments:
    Test read write key.vi ‏58 KB

    StepanieO,
    I finally had a change to play around with the cFP file write and read again.  I was able to write a the cFP and read the file back using write to spreadsheet and read from spreadsheet.  The one problem I can't seem to figure out is how you browse the cFP to select a file.  If I enter the file name and path into the string command it works.  But If I try to browse the cFP, the browse button only shows the computer hard drives.  Is there a way to browse the cFP controller for a specific file?
    Thank you for the help.
    Danny
    Danny
    Attachments:
    Write to spreadsheet.vi ‏18 KB

  • How to write and read Japanese on my Nokia E5

    I am trying to find out how I can write and read Japanese on my Nokia E5.
    I even don't knwo if it's possible...
    Does anyone have the answer???

    Hello ikokitakun,
    I believe you have to load a version of software on your phone that has the Japanese language pack in it because the version of software on the phone only has the languages for the region that you bought the phone in. for example if i bought my phone in NZ it would have English, Malaysian and maybe Philippino. There are "dodgey" places you can go to get the software changed but if you do this you void your warranty so be careful. Nokia doesn't condone the changing of regional software.
    Hope this helps
    -Cheers
    "Freedom is the only way, yeah!"

  • How to write and read data in a specific memory location ??

    Hi Everyone:
    Does anyone know how to write and read data in a specific memory location by using Java ?
    I need pointers, but I don't know how to do it ??
    Thanks for answering
    Rodger

    Hi Everyone:
    Does anyone know how to write and read data in a
    specific memory location by using Java ?
    I need pointers, but I don't know how to do it ??
    Thanks for answering
    RodgerWith Java you cannot write to a specific memory location. Java does not have pointers. If you really want to do it, you need to use JNI, i.e write the required functions in C (or other languages that support pointers) and make those functions available to Java (through JNI). This approach is not portable. You can have a look at http://java.sun.com/docs/books/tutorial/native1.1/index.html
    Regards.

  • How to write and read array on ObjectOutputStream............??

    Hello All...........,
    I have done some code for applet and servlet communication in which i writes "String " as an object and gets reply from servlet as a string as follows:
               // send data to the servlet
                            String input="hello there.....";
                   URLConnection con = getServletConnection();
                   OutputStream outstream = con.getOutputStream();
                   ObjectOutputStream oos = new ObjectOutputStream(outstream);
                   oos.writeObject(input);
                   oos.flush();
                   oos.close();
                   // receive result from servlet
                   InputStream instr = con.getInputStream();
                   ObjectInputStream inputFromServlet = new ObjectInputStream(instr);
                   String result =(String) inputFromServlet.readObject();
                             outputField.setText(result);
                           //outputField.setText("good morning");
                   inputFromServlet.close();
                   instr.close();This code is same at servlet end.
    But now i want to pass an int array.How to pass int[] as an object.
    It is giving me error if i pass int array as int array[]={1,2,3}; oos.writeObject(array); Why is it so?
    Can anybody tell me how to write and read int array[].
    Thanks.
    Shraddha.

    hello kaj,
    I am trying to write as follows
    while writting:
    int array[]={1,2,3,4,5};
    URLConnection con = getServletConnection();
    OutputStream outstream = con.getOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(outstream);
    oos.writeObject(array);
    oos.flush();
    oos.close();
    while reading:
    InputStream instr = con.getInputStream();
    ObjectInputStream inputFromServlet = new ObjectInputStream(instr);
    int result[] =(int []) inputFromServlet.readObject();
    Thanks,
    Really imp for me.

  • I want to write and read a hex file from the flash buffer of the microcontroller through the USB serial port

    hello sir,
    I am developing a GUI screen from that i want to write and read a hex file from the flash buffer of the microcontroller through the USB serial port. the driver i am using is FTDID2XX driver.if anyone having examples of loading file through serial port.Please reply me .
    Thanks

    Looks like you should post your request in the LabVIEW forum, this one here preferentially is for LabWindows/CVI...

  • Could we write and read from a external drive using a IPad?

    √could we write and read from a external drive using a IPad?

    No, the iPad doesn't work that way. The only thing you can access is camera cards (with the adaptor).
    Matt

  • Interruptions when I use "Write" and "Read" in the same vi.

    When I use "Port Write" and "Port Read" together in the same vi and I set the output to be high level, the signal becomes oscillatory. I have read one anterior message about similar problem (using "Write to Digital Line" and "Read from Digital Line" instead of "Port Write" and "Port Read") and I proceeded as the solution suggested in the answer. However, it didn´t work.
    Attached, I am sending the vi I used to test the solution.
    How can I fix this problem?
    Attachments:
    IO.vi ‏35 KB

    Hi Spencer!
    The device I am using is a PCI6024-E board. I have contacted the NI Suport and now I see what I was doing wrong: in fact, I was calling a DIO Port Config.vi for each of the ports ("Port Read" and "Port "Write"), but it was done inside of a While loop (usually, most of the applications here in the lab are recursive, so it´s common for us to use big while loops for the whole program). Putting them outside (as you said, at the beginning of the program), it worked! Actually, I can´t see any reason for the program to work when the calling is outside the loop, but the important is that now it´s running properly.
    Thanks a lot, Spencer!

  • Should I use DB_INIT_CDB while open DB_ENV(multiple writer and reader)?

    My version is db-4.7.25.NC
    I want to use BDB as backend for BBS, so multiple writer and multiple reader are not avoidable.
    My question is what flags I should select while open DB_ENV and DB, DB_THREAD or else?
    DB_INIT_CDB can support only writer thread, I wonder it could meet my requirement?
    Any suggestion, welcom!
    Edited by: user11335524 on Jun 30, 2009 11:37 PM

    The <tt>DB_INIT_CDB</tt> flag only permits one writer <i>at a time</i>. Berkeley DB uses locking internally to enforce this constraint, so if two application threads try to update at the same time, one of them will wait for the other. The <tt>DB_THREAD</tt> flag is required if multiple threads will share the same <tt>DB_ENV</tt> or <tt>DB</tt> handle.
    Regards,
    Michael Cahill, Oracle Berkeley DB.

  • Java - Write And Read From memory Like CheatEngine ( Writing not working?)

    Hello Oracle Forum
    I came here some time ago to ask about javaFX , i solved all my issues and im right now waiting for javaFx tot ake over swing and hmm, im working on learning LIBGDX to create games in java.
    However, im in need to create an app to change values of memory to fix a bug in an old program that i have, and the only way until now is using cheatEngine, So i decided to take a tutorial and learn how to do that in java.
    Well, im able to read from the memory but the write isnt working somehow... Im posting the code here, if anyone can give me a hint, i would thank and a lot, because theres a community that really needs this app to automate the fix without using cheat engine.
    package MainStart;
    import com.br.HM.User32;
    import com.br.kernel.Kernel32;
    import com.sun.jna.Memory;
    import com.sun.jna.Native;
    import com.sun.jna.Pointer;
    import com.sun.jna.ptr.IntByReference;
    public class Cheater {
        static Kernel32 kernel32 = (Kernel32) Native.loadLibrary("kernel32", Kernel32.class);
        static User32 user32 = (User32) Native.loadLibrary("user32", User32.class);
        static int readRight = 0x0010;
        static int writeRight = 0x0020;
        //static int PROCESS_VM_OPERATION = 0x0008;
        public static void main(String[] args) {
            //Read Memory
            //MineSweeper = Campo Minado
            int pid = getProcessId("Campo Minado"); // get our process ID
            System.out.println("Pid = " + pid);
            Pointer readprocess = openProcess(readRight, pid); // open the process ID with read priviledges.
            Pointer writeprocess = openProcess(writeRight, pid);
            int size = 4; // we want to read 4 bytes
            int address = 0x004053C8;
            //Read Memory
            Memory read = readMemory(readprocess, address, size); // read 4 bytes of memory starting at the address 0x00AB0C62.
            System.out.println(read.getInt(0)); // print out the value!      
            //Write Memory
            int writeMemory = writeMemory(writeprocess, address, new short[0x22222222]);
            System.out.println("WriteMemory :" + writeMemory);
            Memory readM = readMemory(readprocess, address, size);
            System.out.println(readM.getInt(0));
        public static int writeMemory(Pointer process, int address, short[] data) {
            IntByReference written = new IntByReference(0);
            Memory toWrite = new Memory(data.length);
            for (long i = 0; i < data.length; i++) {
                toWrite.setShort(0, data[new Integer(Long.toString(i))]);
            boolean b = kernel32.WriteProcessMemory(process, address, toWrite, data.length, written);
            System.out.println("kernel32.WriteProcessMemory : " + b); // Retorna false
            return written.getValue();
        public static Pointer openProcess(int permissions, int pid) {
            Pointer process = kernel32.OpenProcess(permissions, true, pid);
            return process;
        public static int getProcessId(String window) {
            IntByReference pid = new IntByReference(0);
            user32.GetWindowThreadProcessId(user32.FindWindowA(null, window), pid);
            return pid.getValue();
        public static Memory readMemory(Pointer process, int address, int bytesToRead) {
            IntByReference read = new IntByReference(0);
            Memory output = new Memory(bytesToRead);
            kernel32.ReadProcessMemory(process, address, output, bytesToRead, read);
            return output;
    package com.br.HM;
    import com.sun.jna.Native;
    import com.sun.jna.Pointer;
    import com.sun.jna.Structure;
    import com.sun.jna.platform.win32.WinDef.RECT;
    import com.sun.jna.ptr.ByteByReference;
    import com.sun.jna.ptr.IntByReference;
    import com.sun.jna.win32.StdCallLibrary.StdCallCallback;
    import com.sun.jna.win32.W32APIOptions;
    * Provides access to the w32 user32 library. Incomplete implementation to
    * support demos.
    * @author Todd Fast, [email protected]
    * @author [email protected]
    public interface User32 extends W32APIOptions {
        User32 INSTANCE = (User32) Native.loadLibrary("user32", User32.class, DEFAULT_OPTIONS);
        Pointer GetDC(Pointer hWnd);
        int ReleaseDC(Pointer hWnd, Pointer hDC);
        int FLASHW_STOP = 0;
        int FLASHW_CAPTION = 1;
        int FLASHW_TRAY = 2;
        int FLASHW_ALL = (FLASHW_CAPTION | FLASHW_TRAY);
        int FLASHW_TIMER = 4;
        int FLASHW_TIMERNOFG = 12;
        public static class FLASHWINFO extends Structure {
            public int cbSize;
            public Pointer hWnd;
            public int dwFlags;
            public int uCount;
            public int dwTimeout;
        int IMAGE_BITMAP = 0;
        int IMAGE_ICON = 1;
        int IMAGE_CURSOR = 2;
        int IMAGE_ENHMETAFILE = 3;
        int LR_DEFAULTCOLOR = 0x0000;
        int LR_MONOCHROME = 0x0001;
        int LR_COLOR = 0x0002;
        int LR_COPYRETURNORG = 0x0004;
        int LR_COPYDELETEORG = 0x0008;
        int LR_LOADFROMFILE = 0x0010;
        int LR_LOADTRANSPARENT = 0x0020;
        int LR_DEFAULTSIZE = 0x0040;
        int LR_VGACOLOR = 0x0080;
        int LR_LOADMAP3DCOLORS = 0x1000;
        int LR_CREATEDIBSECTION = 0x2000;
        int LR_COPYFROMRESOURCE = 0x4000;
        int LR_SHARED = 0x8000;
        Pointer FindWindowA(String winClass, String title);
        int GetClassName(Pointer hWnd, byte[] lpClassName, int nMaxCount);
        public static class GUITHREADINFO extends Structure {
            public int cbSize = size();
            public int flags;
            Pointer hwndActive;
            Pointer hwndFocus;
            Pointer hwndCapture;
            Pointer hwndMenuOwner;
            Pointer hwndMoveSize;
            Pointer hwndCaret;
            RECT rcCaret;
        boolean GetGUIThreadInfo(int idThread, GUITHREADINFO lpgui);
        public static class WINDOWINFO extends Structure {
            public int cbSize = size();
            public RECT rcWindow;
            public RECT rcClient;
            public int dwStyle;
            public int dwExStyle;
            public int dwWindowStatus;
            public int cxWindowBorders;
            public int cyWindowBorders;
            public short atomWindowType;
            public short wCreatorVersion;
        boolean GetWindowInfo(Pointer hWnd, WINDOWINFO pwi);
        boolean GetWindowRect(Pointer hWnd, RECT rect);
        int GetWindowText(Pointer hWnd, byte[] lpString, int nMaxCount);
        int GetWindowTextLength(Pointer hWnd);
        int GetWindowModuleFileName(Pointer hWnd, byte[] lpszFileName, int cchFileNameMax);
        int GetWindowThreadProcessId(Pointer hWnd, IntByReference lpdwProcessId);
        interface WNDENUMPROC extends StdCallCallback {
             * Return whether to continue enumeration.
            boolean callback(Pointer hWnd, Pointer data);
        boolean EnumWindows(WNDENUMPROC lpEnumFunc, Pointer data);
        boolean EnumThreadWindows(int dwThreadId, WNDENUMPROC lpEnumFunc, Pointer data);
        boolean FlashWindowEx(FLASHWINFO info);
        Pointer LoadIcon(Pointer hInstance, String iconName);
        Pointer LoadImage(Pointer hinst, // handle to instance
                String name, // image to load
                int type, // image type
                int xDesired, // desired width
                int yDesired, // desired height
                int load // load options
        boolean DestroyIcon(Pointer hicon);
        int GWL_EXSTYLE = -20;
        int GWL_STYLE = -16;
        int GWL_WNDPROC = -4;
        int GWL_HINSTANCE = -6;
        int GWL_ID = -12;
        int GWL_USERDATA = -21;
        int DWL_DLGPROC = 4;
        int DWL_MSGRESULT = 0;
        int DWL_USER = 8;
        int WS_EX_COMPOSITED = 0x20000000;
        int WS_EX_LAYERED = 0x80000;
        int WS_EX_TRANSPARENT = 32;
        int GetWindowLong(Pointer hWnd, int nIndex);
        int SetWindowLong(Pointer hWnd, int nIndex, int dwNewLong);
        int LWA_COLORKEY = 1;
        int LWA_ALPHA = 2;
        int ULW_COLORKEY = 1;
        int ULW_ALPHA = 2;
        int ULW_OPAQUE = 4;
        boolean SetLayeredWindowAttributes(Pointer hwnd, int crKey,
                byte bAlpha, int dwFlags);
        boolean GetLayeredWindowAttributes(Pointer hwnd,
                IntByReference pcrKey,
                ByteByReference pbAlpha,
                IntByReference pdwFlags);
         * Defines the x- and y-coordinates of a point.
        public static class POINT extends Structure {
            public int x, y;
         * Specifies the width and height of a rectangle.
        public static class SIZE extends Structure {
            public int cx, cy;
        int AC_SRC_OVER = 0x00;
        int AC_SRC_ALPHA = 0x01;
        int AC_SRC_NO_PREMULT_ALPHA = 0x01;
        int AC_SRC_NO_ALPHA = 0x02;
        public static class BLENDFUNCTION extends Structure {
            public byte BlendOp = AC_SRC_OVER; // only valid value
            public byte BlendFlags = 0; // only valid value
            public byte SourceConstantAlpha;
            public byte AlphaFormat;
        boolean UpdateLayeredWindow(Pointer hwnd, Pointer hdcDst,
                POINT pptDst, SIZE psize,
                Pointer hdcSrc, POINT pptSrc, int crKey,
                BLENDFUNCTION pblend, int dwFlags);
        int SetWindowRgn(Pointer hWnd, Pointer hRgn, boolean bRedraw);
        int VK_SHIFT = 16;
        int VK_LSHIFT = 0xA0;
        int VK_RSHIFT = 0xA1;
        int VK_CONTROL = 17;
        int VK_LCONTROL = 0xA2;
        int VK_RCONTROL = 0xA3;
        int VK_MENU = 18;
        int VK_LMENU = 0xA4;
        int VK_RMENU = 0xA5;
        boolean GetKeyboardState(byte[] state);
        short GetAsyncKeyState(int vKey);
    package com.br.kernel;
    import com.sun.jna.*;
    import com.sun.jna.win32.StdCallLibrary;
    import com.sun.jna.ptr.IntByReference;
    // by deject3d
    public interface Kernel32 extends StdCallLibrary
        // description from msdn
        //BOOL WINAPI WriteProcessMemory(
        //__in   HANDLE hProcess,
        //__in   LPVOID lpBaseAddress,
        //__in   LPCVOID lpBuffer,
        //__in   SIZE_T nSize,
        //__out  SIZE_T *lpNumberOfBytesWritten
        boolean WriteProcessMemory(Pointer p, int address, Pointer buffer, int size, IntByReference written);
        //BOOL WINAPI ReadProcessMemory(
        //          __in   HANDLE hProcess,
        //          __in   LPCVOID lpBaseAddress,
        //          __out  LPVOID lpBuffer,
        //          __in   SIZE_T nSize,
        //          __out  SIZE_T *lpNumberOfBytesRead
        boolean ReadProcessMemory(Pointer hProcess, int inBaseAddress, Pointer outputBuffer, int nSize, IntByReference outNumberOfBytesRead);
        //HANDLE WINAPI OpenProcess(
        //  __in  DWORD dwDesiredAccess,
        //  __in  BOOL bInheritHandle,
        //  __in  DWORD dwProcessId
        Pointer OpenProcess(int desired, boolean inherit, int pid);
        /* derp */
        int GetLastError();
    http://pastebin.com/Vq8wfy39

    Hello there,
    this tutorial was exactly what I needed, so thank you.
    Your problem seems to be in this line:
    int writeMemory = writeMemory(writeprocess, address, new short[0x22222222]); 
    The problem is, you're creating a new short array with the length of 0x22222222. Which not only results in an java.lang.OutOfMemoryError: Java heap space
    but also, if it would work, would create an empty array with the length of 0x22222222.
    I think you want to write 0x22222222 as value in your address.
    Correctly stored the code you'd need to write would be:
    short[] sarray = new short[]{(short) 0x22222222};
    But because the value is too long for the short, the value stored in your array would be the number 8738.
    I think, what you want to do is to store the number 572662306, which would be the hex value, stored in an int variable.
    So first of all you need to strip down your hex-value to shorts:
    Short in Java uses 16 Bit = 2 Byte. 0x22222222 -> 0x2222 for your high byte and 0x2222 for your low byte
    So your array would be
    short[] sarray = new short[]{0x2222,0x2222};//notice, that sarray[0] is the lowbyte and sarray[1] the high byte, if you want to store 20 it would be new short[]{20,0} or if you use hex new short[]{0x14,0x00}
    The next part is your writeToMemory Method. If I'm right, the method in the tutorial is a little bit wrong. The right version should be this:
    public static int writeMemory(Pointer process, int address, short[] data) {
      IntByReference written = new IntByReference(0);
      int size = data.length*Short.SIZE/8;
      Memory toWrite = new Memory(size);
      for (int i = 0; i < data.length; i++) {
      toWrite.setShort(i*Short.SIZE/8,
      data[i]);
      boolean b = kernel32.WriteProcessMemory(process, address, toWrite,
      size, written);
      return written.getValue();
    You need to calculate your offset right. And the size of your memory. Maybe you could write this method not with shorts, but with integers. But this should work.
    If you pass your new array to this function, it should write 0x22222222 to your adress. If you read out your toWrite value with toWrite.getInt(0) you get the right value.
    And there is one more thing. In order to write data to a process, you need to grant two access rights:
    A handle to the process memory to be modified. The handle must have PROCESS_VM_WRITE and PROCESS_VM_OPERATION access to the process.
    You have to grant the right to write data: PROCESS_VM_WRITE: 0x0020 and PROCESS_VM_OPERATION: 0x0008
    So your writeProcess needs to get initialized this way:
    Pointer writeprocess = openProcess(0x0020|0x0008,pid);
    I hope this works for you. Let me know.
    Greetings
    Edit:
    Because every data you write will be 1 byte to whatever count of byte I think the best way is to use the following method to write data to the memory:
    public static void writeMemory(Pointer process, long address, byte[] data)
      int size = data.length;
      Memory toWrite = new Memory(size);
      for(int i = 0; i < size; i++)
      toWrite.setByte(i, data[i]);
      boolean b = kernel32.WriteProcessMemory(process, address, toWrite, size, null);
    You can see some changes. First I changed all address values from int to long, because some addresses are out of range. And with all, i mean all. Not only in writeMemory, but also in readMemory and in your kernel32 Class.
    Second I don't use the IntByReference anymore..
    To use this method you need to store your data the following way if you would write 4 Byte data:
    byte[] values = new byte[]{0x14,0x00,0x00,0x00};
    This value would be the number 20. Index 0 will be the lowest byte and index 3 will be the highest byte.
    And one more thing I wrote is an method which you can use to calculate your address if you have a baseAddress.
    If you restart your program/game your old addresses won't point at the same values of your game. With some research (I use CheatEngine) you can get the baseaddress. This one will alway be the same.
    To get from your baseaddress to the dynamic adress you use offsets.
    public static long findDynAddy(Pointer process, int[] offsets, long baseAddress)
      long pointer = baseAddress;
      int size = 4;
      Memory pTemp = new Memory(size);
      long pointerAddress = 0;
      for(int i = 0; i < offsets.length; i++)
      if(i == 0)
      kernel32.ReadProcessMemory(process, pointer, pTemp, size, null);
      pointerAddress = ((pTemp.getInt(0)+offsets[i]));
      if(i != offsets.length-1)
      kernel32.ReadProcessMemory(process, pointerAddress, pTemp, size, null);
      return pointerAddress;
    This methods gets a process, an array of offsets (hex-values) and your baseadress and returns the dynamic address.
    For Solitaire the following code would give you the address to the score:
    long baseAddr = 0x10002AFA8L;
      int[] offsets = new int[]{0x50,0x14};
      long addr = findDynAddy(process, offsets, baseAddr);
    If somebody wants to get the whole code (user32, kernel32 and the cheater) just pm me and I will give you a link.

Maybe you are looking for

  • P.A. System for Small Room

    I have a MacBook Pro. A TubePRE pre-amp. And a couple of wireless Audio-Technica mics. I usually use a Heil PR40 for podcasts and Skype conferences. But I need to amplify my wife's voice a bit for a presentation she is doing next week. About 40 in at

  • Error 10003 at AI Control

    Hi, When I start to run 25K Functional Test System of SofTest Designs Corp. I receive following error massages 1. ERROR 10007 occurred at DIO port Conf. Possible Reasons: Ni - DAQ LV: A channel, port, or counter is out of range for the device type or

  • Anglican iCal calendar

    I have been trying to search for an iCal calendar for any Anglican church holidays, but coming up empty.  Was hoping someone might point me in the right direction. Thanks

  • How to add tracks to playlist

    how to add tracks to playlist

  • When i turn my imac on it displays a circle with a line thru it why

    When I turn my imac on it displays a circle with a line going threw it and says its loading but nothing appears on the screen. What should I do?